Line |
Branch |
Exec |
Source |
1 |
|
|
// Copyright (c) 2021-2024 ChilliBits. All rights reserved. |
2 |
|
|
|
3 |
|
|
#include "Driver.h" |
4 |
|
|
|
5 |
|
|
// GCOV_EXCL_START |
6 |
|
|
|
7 |
|
− |
void Driver::createInterface() { |
8 |
|
|
// Allow positional args |
9 |
|
− |
app.positionals_at_end(); |
10 |
|
− |
app.require_subcommand(0); |
11 |
|
− |
app.allow_extras(false); |
12 |
|
− |
app.footer("(c) Marc Auberer 2021-2024"); |
13 |
|
|
|
14 |
|
|
// Add version flag |
15 |
|
− |
const std::string versionName(SPICE_VERSION); |
16 |
|
− |
const std::string builtBy(SPICE_BUILT_BY); |
17 |
|
− |
const std::string versionString = "Spice version " + versionName + "\nbuilt by: " + builtBy + "\n\n(c) Marc Auberer 2021-2024"; |
18 |
|
− |
app.set_version_flag("--version,-v", versionString); |
19 |
|
− |
} |
20 |
|
|
|
21 |
|
− |
void Driver::addOptions(bool &updateRefs, bool &runBenchmarks, bool &enableLeakDetection, bool &skipNonGitHubTests) { |
22 |
|
|
// --update-refs |
23 |
|
− |
app.add_flag<bool>("--update-refs,-u", updateRefs, "Update test reference files"); |
24 |
|
|
// --run-benchmarks |
25 |
|
− |
app.add_flag<bool>("--run-benchmarks,-b", runBenchmarks, "Also run benchmarks and check baseline values"); |
26 |
|
|
// --leak-detection |
27 |
|
− |
app.add_flag<bool>("--leak-detection,-l", enableLeakDetection, "Use Valgrind on tests to detect memory leaks"); |
28 |
|
|
// --skip-github-tests |
29 |
|
− |
app.add_flag<bool>("--skip-github-tests,-gh", skipNonGitHubTests, "Skip non-working tests on GitHub Actions"); |
30 |
|
− |
} |
31 |
|
|
|
32 |
|
|
/** |
33 |
|
|
* Start the parsing process |
34 |
|
|
* |
35 |
|
|
* @param argc Argument count |
36 |
|
|
* @param argv Argument vector |
37 |
|
|
* @return Return code |
38 |
|
|
*/ |
39 |
|
− |
int Driver::parse(int argc, char **argv) { |
40 |
|
|
try { |
41 |
|
− |
app.parse(argc, argv); |
42 |
|
− |
} catch (const CLI::ParseError &parseError) { |
43 |
|
− |
return app.exit(parseError); |
44 |
|
− |
} |
45 |
|
− |
return 0; |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
// GCOV_EXCL_STOP |
49 |
|
|
|