GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 0 / 25 / 25
Functions: -% 0 / 3 / 3
Branches: -% 0 / 56 / 56

test/driver/TestDriver.cpp
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 #include "TestDriver.h"
4
5 #include "util/CommonUtil.h"
6
7 // GCOV_EXCL_START
8 namespace spice::testing {
9
10 TestDriverCliOptions testDriverCliOptions;
11
12 void TestDriver::createInterface() {
13 // Allow positional args
14 app.allow_non_standard_option_names();
15 app.positionals_at_end();
16 app.require_subcommand(0);
17 app.allow_extras(false);
18 app.footer("(c) Marc Auberer 2021-2026");
19
20 // Add version flag
21 app.set_version_flag("--version,-v", compiler::CommonUtil::buildVersionInfo());
22 }
23
24 void TestDriver::addOptions() {
25 // --update-refs
26 CLI::Option *updateRefsOpt = app.add_flag<bool>("--update-refs", testDriverCliOptions.updateRefs, "Update test reference files");
27 // --run-benchmarks
28 app.add_flag<bool>("--run-benchmarks", testDriverCliOptions.runBenchmarks, "Also run benchmarks and check baseline values");
29 // --leak-detection
30 app.add_flag<bool>("--leak-detection", testDriverCliOptions.enableLeakDetection, "Use Valgrind on tests to detect memory leaks");
31 // --is-github-actions
32 app.add_flag<bool>("--is-github-actions", testDriverCliOptions.isGitHubActions, "Skip tests that are not supported to run on GitHub Actions");
33 // --skip-sanitizer-tests
34 app.add_flag<bool>("--skip-sanitizer-tests", testDriverCliOptions.skipSanitizerTests, "Skip tests that exercise Spice language sanitizers (e.g. ASAN, TSAN, MSAN, TYSAN)");
35 // --verbose
36 app.add_flag<bool>("--verbose", testDriverCliOptions.isVerbose, "Print debug output for the test runner");
37 // --coverage
38 CLI::Option *coverageOpt =
39 app.add_flag<bool>("--coverage", testDriverCliOptions.enableCoverage,
40 "Compile and run test programs with Spice code coverage instrumentation enabled, skipping all "
41 "reference output comparisons (debug info and coverage counters change the generated code)");
42 // Coverage mode never compares against (or writes) reference files, so combining it with --update-refs would silently
43 // overwrite tracked fixtures with coverage-instrumented, no-longer-comparable output. Reject the combination outright.
44 coverageOpt->excludes(updateRefsOpt);
45 }
46
47 /**
48 * Start the parsing process
49 *
50 * @param argc Argument count
51 * @param argv Argument vector
52 * @return Return code
53 */
54 int TestDriver::parse(int argc, char **argv) {
55 try {
56 app.parse(argc, argv);
57 return 0;
58 } catch (const CLI::ParseError &parseError) {
59 return app.exit(parseError);
60 }
61 }
62
63 } // namespace spice::testing
64
65 // GCOV_EXCL_STOP
66