diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 15:56:41 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 15:56:41 +0000 |
| commit | d953e2acec913027c49520f2db5aa6d8b55e9fba (patch) | |
| tree | e05cabd7d6c84991191e9c92b9ff31bd35c8f5bc /tests/run.pl | |
| parent | 8754a17536aa70e1e4ed3b9f8e9d03727ef2c3ef (diff) | |
test(harness): build C/C++ objects from case manifests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/run.pl')
| -rw-r--r-- | tests/run.pl | 22 |
1 files changed, 21 insertions, 1 deletions
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, |
