aboutsummaryrefslogtreecommitdiff
path: root/tests/run.pl
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-17 09:23:04 +0000
committer_ov4 <ov4@ov4.org>2026-10-17 09:23:04 +0000
commit50186a23cd62fc6ce120f6114b428dc5c26b5a56 (patch)
treefb36447a7f8c932fcf2cd745901b538912eacfae /tests/run.pl
parent9467ae311ddc0ce8b4c329f3dbcec88fb279719d (diff)
test(multifile): cover imports, shared globals and exception propagation
Allow fixtures to pass ordered source lists and require file-qualified negative diagnostics. Add native and runner cases for cross-unit calls, global mutation and shadowing, transitive imports, types, MAIN status, exception catches, runtime failures and destructor unwinding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/run.pl')
-rw-r--r--tests/run.pl23
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/run.pl b/tests/run.pl
index 41437de..54cd10c 100644
--- a/tests/run.pl
+++ b/tests/run.pl
@@ -113,13 +113,16 @@ sub check_diagnostics {
my @matching = grep { /error:/ && /$reason/ } @lines;
my $found = 0;
for my $line (@matching) {
- if ($line =~ /\bline $line_no\b/) {
+ my $file = $expectation->{file};
+ if ($line =~ /\bline $line_no\b/ &&
+ (!defined($file) || $line =~ /\bline $line_no in \Q$file\E(?:\s|$)/)) {
$found = 1;
last;
}
}
if (!$found) {
push @errors, 'missing error /' . $reason . '/ at line ' . $line_no
+ . (defined($expectation->{file}) ? ' in ' . $expectation->{file} : '')
. '; matching diagnostics: [' . join(', ', map { show_bytes($_) } @matching) . ']';
}
}
@@ -339,7 +342,15 @@ sub main {
run_mode => $opt_run_mode,
failures => [],
};
- my $source = File::Spec->catfile($case_dir, 'program.cps');
+ my @sources = map { File::Spec->catfile($case_dir, split(m{/}, $_)) }
+ @{$config->{sources} // ['program.cps']};
+ my @expectations = map {
+ my %expectation = %{$_};
+ if (defined($expectation{file})) {
+ $expectation{file} = File::Spec->catfile($case_dir, split(m{/}, $expectation{file}));
+ }
+ \%expectation;
+ } @{$config->{errors} // []};
my $attempt = sub {
my ($label, $code) = @_;
@@ -367,7 +378,7 @@ sub main {
write_file($target, $sentinel);
}
my $result = run_command($commands,
- [$cpsc_abs, $source, @flags, '-o', $target], $work, '', 120);
+ [$cpsc_abs, @sources, @flags, '-o', $target], $work, '', 120);
my $preservation_error;
if ($existing && (!-f $target || read_file($target) ne $sentinel)) {
$preservation_error = 'compilation failure overwrote existing output';
@@ -384,7 +395,7 @@ sub main {
if (defined($captured_error)) {
die "$captured_error\n";
}
- check_diagnostics($captured_result, $config->{errors});
+ check_diagnostics($captured_result, \@expectations);
},
);
}
@@ -443,12 +454,12 @@ sub main {
my $target = File::Spec->catfile($work,
$IS_WINDOWS ? 'program.exe' : 'program.bin');
my $compiled = run_command($commands,
- [$cpsc_abs, $source, '-o', $target], $work, '', 120);
+ [$cpsc_abs, @sources, '-o', $target], $work, '', 120);
check_result($compiled, '');
$command = [$target];
}
else {
- $command = [$cpsc_abs, $source, '-r'];
+ $command = [$cpsc_abs, @sources, '-r'];
}
my $exec_timeout = exists($config->{timeout}) ? $config->{timeout} + 0 : 30;
my $result = run_command($commands, $command, $work, $data, $exec_timeout);