11#pragma once
22
3- #include < string>
4- #include < string_view>
5-
6- #ifdef CPPSPEC_SEMIHOSTED
7- #include < sys/stat.h>
8- #include < cstring>
9- #else
103#include < argparse/argparse.hpp>
11- #include < filesystem>
124#include < fstream>
13- #endif
14-
5+ #include < string >
6+ # include < string_view >
157#include " formatters/junit_xml.hpp"
168#include " formatters/progress.hpp"
179#include " formatters/tap.hpp"
@@ -31,31 +23,6 @@ inline std::string file_name(std::string_view path) {
3123}
3224
3325inline 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
5926 std::filesystem::path executable_path = argv[0 ];
6027 std::string executable_name = executable_path.filename ().string ();
6128 argparse::ArgumentParser program{executable_name};
@@ -94,16 +61,11 @@ inline Runner parse(int argc, char** const argv) {
9461
9562 auto junit_output_filepath = program.get <std::string>(" --output-junit" );
9663 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-
10164 // open file stream
10265 auto * file_stream = new std::ofstream (junit_output_filepath);
10366 auto junit_output = std::make_shared<Formatters::JUnitXML>(*file_stream, false );
10467 return Runner{formatter, junit_output};
10568 }
10669 return Runner{formatter};
107- #endif
10870}
10971} // namespace CppSpec
0 commit comments