libshit_standalone.cpp (724B)
1 // Standalone test runner for libshit, only used when building libshit directly 2 3 #include <libshit/options.hpp> 4 5 #include <vector> 6 7 int main(int argc, char** argv) 8 { 9 auto& parser = Libshit::OptionParser::GetGlobal(); 10 parser.FailOnNonArg(); 11 12 // doctest ignores unknown options, --test eats all options, so just fake a 13 // --test at the end of the argument list, this way if the user didn't 14 // specify --test, the tests will still run, and if the user specified 15 // --test, that extra --test will be ignored... 16 auto args = Libshit::ArgsToVector(argc, argv); 17 args.push_back("--test"); 18 19 try { parser.Run(args, true); } 20 catch (const Libshit::Exit& e) { return !e.success; } 21 22 return 0; 23 }