mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-09-19 19:19:05 +01:00
Integration tests: Set up CI testing for TypeGraph
CTest can't forward command line arguments to the test runner, so add the option to using an environment variable to enable features instead. CMake issue tracking the feature that would have been needed: https://gitlab.kitware.com/cmake/cmake/-/issues/20470 Tests which aren't passing yet have been disabled in CI.
This commit is contained in:
parent
1bb0c62987
commit
4dc9007166
@ -14,9 +14,17 @@ workflows:
|
||||
name: test-gcc
|
||||
requires:
|
||||
- build-gcc
|
||||
- test:
|
||||
name: test-type-graph-gcc
|
||||
requires:
|
||||
- build-gcc
|
||||
oid_test_args: "-ftype-graph"
|
||||
tests_regex: "OidIntegration\\..*"
|
||||
exclude_regex: ".*inheritance_polymorphic.*|.*fbstring.*"
|
||||
- coverage:
|
||||
requires:
|
||||
- test-gcc
|
||||
- test-type-graph-gcc
|
||||
|
||||
- build:
|
||||
name: build-clang
|
||||
@ -27,6 +35,13 @@ workflows:
|
||||
name: test-clang
|
||||
requires:
|
||||
- build-clang
|
||||
- test:
|
||||
name: test-type-graph-clang
|
||||
requires:
|
||||
- build-clang
|
||||
oid_test_args: "-ftype-graph"
|
||||
tests_regex: "OidIntegration\\..*"
|
||||
exclude_regex: ".*inheritance_polymorphic.*|.*fbstring.*|.*std_string_*|.*multi_arg_tb_.*|.*ignored_a"
|
||||
|
||||
executors:
|
||||
ubuntu-docker:
|
||||
@ -132,6 +147,16 @@ jobs:
|
||||
|
||||
test:
|
||||
executor: big-boy
|
||||
parameters:
|
||||
oid_test_args:
|
||||
type: string
|
||||
default: ""
|
||||
tests_regex:
|
||||
type: string
|
||||
default: ".*"
|
||||
exclude_regex:
|
||||
type: string
|
||||
default: ""
|
||||
working_directory:
|
||||
/tmp/object-introspection
|
||||
steps:
|
||||
@ -155,9 +180,16 @@ jobs:
|
||||
OMP_NUM_THREADS: 1
|
||||
command: |
|
||||
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
||||
ctest --test-dir build/test/ --test-action Test -j 16 \
|
||||
--no-compress-output --output-on-failure \
|
||||
--schedule-random --timeout 60 \
|
||||
OID_TEST_ARGS='<< parameters.oid_test_args >>' ctest \
|
||||
--test-dir build/test/ \
|
||||
--test-action Test \
|
||||
-j 16 \
|
||||
--tests-regex '<< parameters.tests_regex >>' \
|
||||
--exclude-regex '<< parameters.exclude_regex >>' \
|
||||
--no-compress-output \
|
||||
--output-on-failure \
|
||||
--schedule-random \
|
||||
--timeout 60 \
|
||||
--output-junit results.xml
|
||||
- store_test_results:
|
||||
path: build/test/results.xml
|
||||
|
@ -23,6 +23,13 @@ additional options to aid debugging:
|
||||
ctest --test-dir build/test/integration -j$(nproc) [--tests-regex <regex>]
|
||||
```
|
||||
|
||||
Additional command line arguments can be passed to oid by setting the `OID_TEST_ARGS` environment variable, e.g.:
|
||||
|
||||
```sh
|
||||
OID_TEST_ARGS="-fmy-new-feature" build/test/integration/integration_test_runner
|
||||
OID_TEST_ARGS="-Fold-feature" ctest --test-dir build/test/integration
|
||||
```
|
||||
|
||||
## Adding tests
|
||||
|
||||
1. Create a new test definition file in this directory and populate it as needed. See [Test Definition Format](#test-definition-format) for details.
|
||||
|
@ -21,14 +21,17 @@ namespace bp = boost::process;
|
||||
namespace bpt = boost::property_tree;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
bool run_skipped_tests = false;
|
||||
|
||||
namespace {
|
||||
|
||||
std::string oidExe = OID_EXE_PATH;
|
||||
std::string configFile = CONFIG_FILE_PATH;
|
||||
|
||||
bool verbose = false;
|
||||
bool preserve = false;
|
||||
bool preserve_on_failure = false;
|
||||
bool run_skipped_tests = false;
|
||||
std::vector<std::string> extra_feature_args{};
|
||||
std::vector<std::string> global_oid_args{};
|
||||
|
||||
constexpr static OIOpts cliOpts{
|
||||
OIOpt{'h', "help", no_argument, nullptr, "Print this message and exit"},
|
||||
@ -51,9 +54,15 @@ void usage(std::string_view progname) {
|
||||
std::cout << cliOpts;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
if (const char* envArgs = std::getenv("OID_TEST_ARGS")) {
|
||||
boost::split(global_oid_args, envArgs, boost::is_any_of(" "));
|
||||
}
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long(argc, argv, cliOpts.shortOpts(), cliOpts.longOpts(),
|
||||
nullptr)) != -1) {
|
||||
@ -76,7 +85,7 @@ int main(int argc, char* argv[]) {
|
||||
oidExe = fs::absolute(optarg);
|
||||
break;
|
||||
case '\0':
|
||||
extra_feature_args.push_back(std::string("-f") + optarg);
|
||||
global_oid_args.push_back("-f"s + optarg);
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
@ -223,12 +232,12 @@ OidProc OidIntegration::runOidOnProcess(OidOpts opts,
|
||||
"--script-source"s, opts.scriptSource,
|
||||
"--pid"s, std::to_string(targetProcess.id()),
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
|
||||
// Specify feature args first so they can be overridden by extra_args of
|
||||
// specific tests.
|
||||
auto oid_args = extra_feature_args;
|
||||
// The arguments are appended in ascending order of precedence (low -> high)
|
||||
std::vector<std::string> oid_args;
|
||||
oid_args.insert(oid_args.end(), global_oid_args.begin(),
|
||||
global_oid_args.end());
|
||||
oid_args.insert(oid_args.end(), extra_args.begin(), extra_args.end());
|
||||
oid_args.insert(oid_args.end(), default_args.begin(), default_args.end());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user