File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed
Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change 1- #define CATCH_CONFIG_MAIN
1+
2+ #include < exception>
3+ #include < filesystem>
4+ #include < iostream>
5+ #include < system_error>
6+
7+ #define CATCH_CONFIG_RUNNER
28#include " catch.hpp"
39
4- // this is a stub to generate main() jazz.
10+ // io2d uses its own main(), rather than Catch's, so as to set the running
11+ // process' current working directory to that where input data files are
12+ // located.
13+ //
14+ // Catch2 describes how to do a custom main(), at:
15+ // https://github.com/catchorg/Catch2/blob/master/docs/own-main.md
16+
17+ int main (int argc, char * argv[])
18+ {
19+ // For now, set the app's CWD (Current Working Directory) to where the
20+ // app's executable is, presuming this info is available.
21+ if (argc >= 1 && argv[0 ] != nullptr ) {
22+ try {
23+ using namespace std ::filesystem;
24+ current_path (path (argv[0 ]).parent_path ());
25+ } catch (const std::exception & ex) {
26+ std::cerr <<
27+ " ERROR: Unable to set CWD via current_path(). what()=\" " <<
28+ ex.what () <<
29+ " \"\n " ;
30+ return 1 ; // Return a non-zero integer to indicate failure
31+ }
32+ }
33+
34+ return Catch::Session ().run (argc, argv);
35+ }
You can’t perform that action at this time.
0 commit comments