aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-17 15:56:41 +0000
committer_ov4 <ov4@ov4.org>2026-10-17 15:56:41 +0000
commitd953e2acec913027c49520f2db5aa6d8b55e9fba (patch)
treee05cabd7d6c84991191e9c92b9ff31bd35c8f5bc /tests
parent8754a17536aa70e1e4ed3b9f8e9d03727ef2c3ef (diff)
test(harness): build C/C++ objects from case manifests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/run.pl22
2 files changed, 22 insertions, 1 deletions
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 "$<TARGET_FILE: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,