Skip to content

Commit 04d7457

Browse files
committed
Remove non macOS compatible things
1 parent 6849ba2 commit 04d7457

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: |
4444
echo "CC=clang-18" >> $GITHUB_ENV
4545
echo "CXX=clang++-18" >> $GITHUB_ENV
46-
if: ${{ matrix.compiler == 'llvm' && (matrix.os != 'macos-13' || matrix.os != 'macos-15') }}
46+
if: ${{ matrix.compiler == 'llvm' && (matrix.os != 'macos-13' && matrix.os != 'macos-15') }}
4747

4848
- name: Use GCC
4949
run: |

include/formatters/junit_xml.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ struct TestCase {
9090
std::stringstream ss;
9191
ss << start << ">" << std::endl;
9292

93-
ss << *std::ranges::fold_left_first(xml_results,
94-
[](const std::string& acc, const std::string& r) { return acc + "\n" + r; });
93+
ss << std::accumulate(xml_results.begin(), xml_results.end(), std::string{},
94+
[](const std::string& acc, const std::string& r) { return acc + "\n" + r; });
9595
ss << std::endl;
9696
ss << " </testcase>";
9797
return ss.str();
@@ -115,8 +115,18 @@ struct TestSuite {
115115
: id(get_next_id()), name(std::move(name)), time(time), timestamp(timestamp), tests(tests), failures(failures) {}
116116

117117
[[nodiscard]] std::string to_xml() const {
118-
auto timestamp_str =
119-
std::format("{0:%F}T{0:%T}", std::chrono::zoned_time(std::chrono::current_zone(), timestamp).get_local_time());
118+
std::string timestamp_str;
119+
if constexpr (requires { std::chrono::current_zone(); }) {
120+
auto localtime = std::chrono::zoned_time(std::chrono::current_zone(), timestamp).get_local_time();
121+
timestamp_str = std::format("{0:%F}T{0:%T}", localtime);
122+
} else {
123+
// Cludge because macOS doesn't have std::chrono::current_zone() or std::chrono::zoned_time()
124+
std::time_t time_t_timestamp = std::chrono::system_clock::to_time_t(timestamp);
125+
std::tm localtime = *std::localtime(&time_t_timestamp);
126+
std::ostringstream oss;
127+
oss << std::put_time(&localtime, "%Y-%m-%dT%H:%M:%S");
128+
timestamp_str = oss.str();
129+
}
120130

121131
std::stringstream ss;
122132
ss << " "

include/it_base.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <algorithm>
55
#include <functional>
6+
#include <numeric>
67
#include <source_location>
78
#include <string>
89
#include <utility>
@@ -137,11 +138,12 @@ class ItBase : public Runnable {
137138
void clear_results() noexcept { results.clear(); }
138139

139140
[[nodiscard]] Result get_result() const override {
141+
auto default_result = Result::success(this->get_location());
140142
if (results.empty()) {
141-
return Result::success(this->get_location());
143+
return default_result;
142144
}
143145

144-
return *std::ranges::fold_left_first(results, &Result::reduce);
146+
return std::accumulate(results.begin(), results.end(), default_result, &Result::reduce);
145147
}
146148
};
147149

0 commit comments

Comments
 (0)