Skip to content

Commit 8e89433

Browse files
committed
Avoid spurious backtrace when exiting from fatal error.
1 parent 1b1a281 commit 8e89433

File tree

10 files changed

+28
-2
lines changed

10 files changed

+28
-2
lines changed

lkql_jit/lkql_cli/src/main/java/com/adacore/lkql_jit/LKQLChecker.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ protected int executeScript(Context.Builder contextBuilder) {
233233
contextBuilder.option("lkql.ignores", this.args.ignores);
234234
}
235235

236+
// This is needed to make sure that calls to `exitContext` done from within an isolate
237+
// thread (e.g. executing a Java callback from Ada code) directly stop the program instead
238+
// of going it the normal way by raising a special exception, as such exceptions won't be
239+
// handled by the caller when thrown from inside the isolate thread.
240+
contextBuilder.useSystemExit(true);
241+
236242
// Create the context and run the script in it
237243
try (Context context = contextBuilder.build()) {
238244
final Source source = Source.newBuilder("lkql", checkerSource, "checker.lkql").build();

testsuite/drivers/checker_driver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@ def run(self) -> None:
4242

4343
args += ['-r', self.test_env['rule_name']]
4444
args += ['--rules-dir', self.test_env['test_dir']]
45-
args += ['--keep-going-on-missing-file']
45+
46+
if self.test_env.get("keep_going_on_missing_file", False):
47+
args += ['--keep-going-on-missing-file']
4648

4749
# Run the checker
4850
if self.perf_mode:
4951
self.perf_run(args)
5052
else:
51-
self.check_run(args)
53+
# Use `catch_error=False` to avoid failing on non-zero status code,
54+
# as some tests actually exert erroneous behaviors.
55+
self.check_run(args, catch_error=False)
5256

5357
def parse_flagged_lines(self, output: str) -> Flags:
5458
# Compile the pattern to match a checker output
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ERROR: File p.ads not found
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project Prj is
2+
end Prj;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
with P;
2+
3+
package Q is
4+
type T is range 1 .. 5;
5+
6+
subtype U is T;
7+
8+
X : constant P.T := 2;
9+
end Q;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
driver: 'checker'
2+
rule_name: integer_types_as_enum
3+
project: 'prj.gpr'
4+
keep_going_on_missing_file: true

0 commit comments

Comments
 (0)