From d953e2acec913027c49520f2db5aa6d8b55e9fba Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 15:56:41 +0000 Subject: test(harness): build C/C++ objects from case manifests Co-Authored-By: Claude Sonnet 5.5 --- tests/CMakeLists.txt | 1 + tests/run.pl | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1a20f38..1f13dea 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,6 +23,7 @@ foreach(suite i ii iii) "${CMAKE_CURRENT_SOURCE_DIR}/run.pl" --case "${manifest}" --cpsc "$" --run-mode "${CPSC_RUN_MODE}" --perl "${PERL_EXECUTABLE}" + --cc "${CMAKE_C_COMPILER}" --cxx "${CMAKE_CXX_COMPILER}" --seed "${CPSC_TEST_SEED}" --count "${CPSC_TEST_COUNT}" --results "${CMAKE_BINARY_DIR}/test-results" ${reference_args}) set_tests_properties("${suite}/${case_name}" PROPERTIES diff --git a/tests/run.pl b/tests/run.pl index 7b2bd5a..ec4a8e7 100644 --- a/tests/run.pl +++ b/tests/run.pl @@ -288,7 +288,7 @@ sub main { my @args = @_; local @ARGV = @args; my ($opt_case, $opt_cpsc, $opt_run_mode, $opt_reference, $opt_perl, $opt_seed, - $opt_count, $opt_results); + $opt_count, $opt_results, $opt_cc, $opt_cxx); $opt_perl = 'perl'; $opt_seed = ''; $opt_count = 10000; @@ -302,6 +302,8 @@ sub main { 'seed=s' => \$opt_seed, 'count=i' => \$opt_count, 'results=s' => \$opt_results, + 'cc=s' => \$opt_cc, + 'cxx=s' => \$opt_cxx, ); if (!$parsed || !defined($opt_case) || !defined($opt_cpsc) || !defined($opt_run_mode)) { warn "usage: $0 --case MANIFEST --cpsc CPSC --run-mode MODE [options]\n"; @@ -462,6 +464,24 @@ sub main { my $execute = sub { my ($mode) = @_; my $work = workspace($case_dir, $directory, $mode); + my @sources = @sources; + if (@{$config->{objects} // []}) { + # INCLUDE_OBJ resolves beside the source, so run from a copy. + my $tree = File::Spec->catdir($work, 'src'); + make_path($tree); + copy_tree($case_dir, $tree); + @sources = map { File::Spec->catfile($tree, split(m{/}, $_)) } + @{$config->{sources} // ['program.cps']}; + for my $object (@{$config->{objects}}) { + my $compiler = $object->{source} =~ /\.c$/ ? $opt_cc : $opt_cxx; + die "objects need --cc and --cxx\n" unless defined $compiler; + my $built = run_command($commands, [$compiler, '-c', + File::Spec->catfile($tree, split(m{/}, $object->{source})), + '-o', File::Spec->catfile($tree, split(m{/}, $object->{output}))], + $work, '', 120); + check_result($built, ''); + } + } my $command; if ($mode eq 'native') { my $target = File::Spec->catfile($work, -- cgit v1.3.1-4-g156e