1
1
#pragma once
2
2
3
- #include < string>
4
- #include < string_view>
5
-
6
- #ifdef CPPSPEC_SEMIHOSTED
7
- #include < sys/stat.h>
8
- #include < cstring>
9
- #else
10
3
#include < argparse/argparse.hpp>
11
- #include < filesystem>
12
4
#include < fstream>
13
- #endif
14
-
5
+ #include < string >
6
+ # include < string_view >
15
7
#include " formatters/junit_xml.hpp"
16
8
#include " formatters/progress.hpp"
17
9
#include " formatters/tap.hpp"
@@ -31,31 +23,6 @@ inline std::string file_name(std::string_view path) {
31
23
}
32
24
33
25
inline Runner parse (int argc, char ** const argv) {
34
- #ifdef CPPSPEC_SEMIHOSTED
35
- int i = 0 ;
36
- for (; i < argc; ++i) {
37
- if (strcmp (argv[i], " -f" ) == 0 ) {
38
- break ;
39
- }
40
- }
41
- if (i == argc) {
42
- return Runner{std::make_shared<Formatters::Progress>()};
43
- std::exit (-1 );
44
- }
45
- std::string format_string = argv[i + 1 ];
46
- if (format_string == " d" || format_string == " detail" ) {
47
- return Runner{std::make_shared<Formatters::Verbose>()};
48
- } else if (format_string == " p" || format_string == " progress" ) {
49
- return Runner{std::make_shared<Formatters::Progress>()};
50
- } else if (format_string == " t" || format_string == " tap" ) {
51
- return Runner{std::make_shared<Formatters::TAP>()};
52
- } else if (format_string == " j" || format_string == " junit" ) {
53
- return Runner{std::make_shared<Formatters::JUnitXML>()};
54
- } else {
55
- std::cerr << " Unrecognized format type" << std::endl;
56
- std::exit (-1 );
57
- }
58
- #else
59
26
std::filesystem::path executable_path = argv[0 ];
60
27
std::string executable_name = executable_path.filename ().string ();
61
28
argparse::ArgumentParser program{executable_name};
@@ -94,16 +61,11 @@ inline Runner parse(int argc, char** const argv) {
94
61
95
62
auto junit_output_filepath = program.get <std::string>(" --output-junit" );
96
63
if (!junit_output_filepath.empty ()) {
97
- // create directories recursively if they don't exist
98
- std::filesystem::path junit_output_path = junit_output_filepath;
99
- std::filesystem::create_directories (junit_output_path.parent_path ());
100
-
101
64
// open file stream
102
65
auto * file_stream = new std::ofstream (junit_output_filepath);
103
66
auto junit_output = std::make_shared<Formatters::JUnitXML>(*file_stream, false );
104
67
return Runner{formatter, junit_output};
105
68
}
106
69
return Runner{formatter};
107
- #endif
108
70
}
109
71
} // namespace CppSpec
0 commit comments