Skip to content

Commit 464fb5f

Browse files
committed
Update
1 parent 343258b commit 464fb5f

File tree

4 files changed

+28
-44
lines changed

4 files changed

+28
-44
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
strategy:
2222
matrix:
2323
os:
24-
- "macos-latest"
24+
- "macos-14"
25+
- "macos-15"
2526
- "ubuntu-20.04"
2627
- "ubuntu-22.04"
2728
- "ubuntu-24.04"
@@ -47,19 +48,8 @@ jobs:
4748
name: "Install clang-16 (for c++20)"
4849
run: |-
4950
brew install llvm@16
50-
echo 'export PATH="/opt/homebrew/opt/llvm@16/bin:$PATH"' >> /Users/runner/.bashrc
51-
echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm@16/lib"' >> /Users/runner/.bashrc
52-
echo 'export CPPFLAGS="-I/opt/homebrew/opt/llvm@16/include"' >> /Users/runner/.bashrc
53-
echo 'export CC=/opt/homebrew/opt/llvm@16/bin/clang' >> /Users/runner/.bashrc
54-
echo 'export CXX=/opt/homebrew/opt/llvm@16/bin/clang++' >> /Users/runner/.bashrc
55-
ls -l /Users/runner/.bashrc
56-
ls -l ~/.bashrc
57-
source ~/.bashrc
58-
echo $SHELL
59-
ls -l /opt/homebrew/opt/llvm@16/bin/clang
60-
ls -l /opt/homebrew/opt/llvm@16/bin/clang
61-
ls -l /opt/homebrew/opt/llvm@16/bin/clang++
62-
clang --version
51+
echo "export CC=/opt/homebrew/opt/llvm@16/bin/clang" >> /Users/runner/.bashrc
52+
echo "export CXX=/opt/homebrew/opt/llvm@16/bin/clang++" >> /Users/runner/.bashrc
6353
6454
- if: "matrix.os == 'ubuntu-20.04'"
6555
name: "Install gcc-10 (for c++20)"
@@ -75,16 +65,17 @@ jobs:
7565
7666
- name: "Log tool versions"
7767
run: |-
78-
command -v clang
79-
command -v gcc
80-
command -v md5sum
81-
command -v python
82-
command -v tar
83-
command -v task
68+
[ -n "$ZSH_VERSION" ] && source ~/.zshrc || { [ -n "$BASH_VERSION" ] && source ~/.bashrc; }
69+
clang --version
70+
gcc --version
71+
g++ --version
72+
md5sum --version
73+
python --version
74+
tar --version
75+
task --version
8476
8577
- name: "Run unit tests"
8678
run: |-
87-
clang --version
88-
source ~/.bashrc
89-
clang --version
79+
[ -n "$ZSH_VERSION" ] && source ~/.zshrc || { [ -n "$BASH_VERSION" ] && source ~/.bashrc; }
80+
task clean
9081
task test-all

src/ystdlib/error_handling/TraceableException.hpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <source_location>
66
#include <string>
77
#include <system_error>
8-
#include <iostream>
98

109
namespace ystdlib::error_handling {
1110
/**
@@ -26,14 +25,7 @@ class TraceableException : public std::exception, public std::source_location {
2625
std::error_code error_code,
2726
std::source_location const& location = std::source_location::current()
2827
)
29-
: TraceableException{error_code, location.function_name(), location} {
30-
std::cout << "HAHA: " << location.function_name() << std::endl;
31-
std::cout << "HAHA: " << location.line() << std::endl;
32-
std::cout << "HAHA: " << location.file_name() << std::endl;
33-
std::cout << "HAHA: " << function_name() << std::endl;
34-
std::cout << "HAHA: " << line() << std::endl;
35-
std::cout << "HAHA: " << file_name() << std::endl;
36-
}
28+
: TraceableException{error_code, location.function_name(), location} {}
3729

3830
explicit TraceableException(
3931
std::error_code error_code,

src/ystdlib/error_handling/test-TraceableException.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
namespace {
1212
constexpr std::string_view cCustomFailureDescription{"This operation has failed."};
13+
} // namespace
1314

15+
namespace ystdlib::test {
1416
class Worker {
1517
public:
1618
YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION(OperationFailed);
@@ -30,20 +32,24 @@ class Worker {
3032
throw OperationFailed(std::make_error_code(std::errc::invalid_argument));
3133
}
3234
};
35+
} // namespace ystdlib::test
36+
37+
using ystdlib::test::Worker;
3338

39+
namespace {
3440
constexpr std::string_view cExecuteWithSuccessFunctionName{
35-
"static void {anonymous}::Worker::execute_with_success()"
41+
"static void ystdlib::test::Worker::execute_with_success()"
3642
};
3743
constexpr std::string_view cExecuteWithFailureFunctionName{
38-
"static void {anonymous}::Worker::execute_with_failure()"
44+
"static void ystdlib::test::Worker::execute_with_failure()"
3945
};
4046
constexpr std::string_view cExecuteWithInvalidArgsFunctionName{
41-
"static void {anonymous}::Worker::execute_with_invalid_args()"
47+
"static void ystdlib::test::Worker::execute_with_invalid_args()"
4248
};
4349
constexpr std::string_view cInvalidArgsErrorMsg{"Invalid argument"};
44-
constexpr auto cExecuteWithSuccessLineNumber{19};
45-
constexpr auto cExecuteWithFailureLineNumber{26};
46-
constexpr auto cExecuteWithInvalidArgsLineNumber{30};
50+
constexpr auto cExecuteWithSuccessLineNumber{21};
51+
constexpr auto cExecuteWithFailureLineNumber{28};
52+
constexpr auto cExecuteWithInvalidArgsLineNumber{32};
4753

4854
#ifdef SOURCE_PATH_SIZE
4955
constexpr auto cRelativePathFileName{std::string_view{__FILE__}.substr(SOURCE_PATH_SIZE)};
@@ -66,17 +72,12 @@ auto capture_exception(Callable&& f) -> ystdlib::error_handling::TraceableExcept
6672
}
6773
} // namespace
6874

69-
#include <iostream>
70-
7175
TEST_CASE("test_traceable_exception_success", "[error_handling][TraceableException]") {
7276
auto const success_exception{capture_exception(Worker::execute_with_success)};
7377
std::error_code const success_error_code{BinaryErrorCode{BinaryErrorCodeEnum::Success}};
7478
REQUIRE((success_error_code.category() == success_exception.error_code().category()));
7579
REQUIRE((success_error_code.value() == success_exception.error_code().value()));
7680
REQUIRE((cSuccessErrorMsg == success_exception.error_code().message()));
77-
std::cout << "A:" << cExecuteWithSuccessFunctionName << std::endl;
78-
std::cout << "B:" << success_exception.what() << std::endl;
79-
std::cout << "C:" << success_exception.function_name() << std::endl;
8081
REQUIRE((cExecuteWithSuccessFunctionName == std::string_view{success_exception.what()}));
8182
REQUIRE((cExecuteWithSuccessFunctionName == success_exception.function_name()));
8283
REQUIRE((cExecuteWithSuccessLineNumber == success_exception.line()));

taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ vars:
1313
G_TEST_BIN_DIR: "{{.G_BUILD_DIR}}/testbin"
1414
G_TEST_TARGET_SUFFIXES:
1515
- "all"
16-
- "testlib"
16+
- "error_handling"
1717

1818
tasks:
1919
clean:

0 commit comments

Comments
 (0)