-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
90 lines (80 loc) · 2.65 KB
/
Copy pathmain.cpp
File metadata and controls
90 lines (80 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <testcoe.hpp>
#include <iostream>
#include <string>
void printHelp()
{
std::cout << "Usage: ./filter_example [options]" << std::endl;
std::cout << "Options:" << std::endl;
std::cout << " --help Display this help message" << std::endl;
std::cout << " --all Run all tests (default)" << std::endl;
std::cout << " --suite=NAME Run only the specified test suite" << std::endl;
std::cout << " --test=SUITE.TEST Run only the specified test" << std::endl;
std::cout << std::endl;
}
int main(int argc, char **argv)
{
// Print intro message
std::cout << "==================================================" << std::endl;
std::cout << " testcoe Test Filtering Example" << std::endl;
std::cout << "==================================================" << std::endl;
std::cout << std::endl;
std::cout << "This example demonstrates testcoe's test filtering capabilities." << std::endl;
std::cout << "You can run all tests, a specific test suite, or a single test." << std::endl;
std::cout << std::endl;
// Initialize testcoe
testcoe::init(&argc, argv);
// Parse command line arguments
bool showHelp = false;
bool runAll = true;
std::string suiteName;
std::string testName;
for (int i = 1; i < argc; ++i)
{
std::string arg = argv[i];
if (arg == "--help")
showHelp = true;
else if (arg == "--all")
runAll = true;
else if (arg.substr(0, 8) == "--suite=")
{
runAll = false;
suiteName = arg.substr(8);
}
else if (arg.substr(0, 7) == "--test=")
{
runAll = false;
std::string fullTest = arg.substr(7);
// Parse "Suite.Test" format
size_t dotPos = fullTest.find('.');
if (dotPos != std::string::npos)
{
suiteName = fullTest.substr(0, dotPos);
testName = fullTest.substr(dotPos + 1);
}
}
}
// Display help if requested
if (showHelp)
{
printHelp();
return 0;
}
// Run tests based on filtering options
if (runAll)
{
std::cout << "Running all tests..." << std::endl;
return testcoe::run();
}
else if (!testName.empty())
{
std::cout << "Running test: " << suiteName << "." << testName << std::endl;
return testcoe::run_test(suiteName, testName);
}
else if (!suiteName.empty())
{
std::cout << "Running suite: " << suiteName << std::endl;
return testcoe::run_suite(suiteName);
}
// Default: run all tests
return testcoe::run();
}