Skip to content

Commit

Permalink
Merge branch 'topic/162' into 'master'
Browse files Browse the repository at this point in the history
Avoid spurious backtrace when exiting from fatal error.

Closes #162

See merge request eng/libadalang/langkit-query-language!216
  • Loading branch information
Roldak committed Apr 30, 2024
2 parents 1a64082 + 8e89433 commit 5ec824e
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 2 deletions.
Expand Up @@ -233,6 +233,12 @@ protected int executeScript(Context.Builder contextBuilder) {
contextBuilder.option("lkql.ignores", this.args.ignores);
}

// This is needed to make sure that calls to `exitContext` done from within an isolate
// thread (e.g. executing a Java callback from Ada code) directly stop the program instead
// of going it the normal way by raising a special exception, as such exceptions won't be
// handled by the caller when thrown from inside the isolate thread.
contextBuilder.useSystemExit(true);

// Create the context and run the script in it
try (Context context = contextBuilder.build()) {
final Source source = Source.newBuilder("lkql", checkerSource, "checker.lkql").build();
Expand Down
10 changes: 10 additions & 0 deletions lkql_jit/pom.xml
Expand Up @@ -147,6 +147,16 @@
<lineEndings>UNIX</lineEndings>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-implicit:class</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
8 changes: 6 additions & 2 deletions testsuite/drivers/checker_driver.py
Expand Up @@ -42,13 +42,17 @@ def run(self) -> None:

args += ['-r', self.test_env['rule_name']]
args += ['--rules-dir', self.test_env['test_dir']]
args += ['--keep-going-on-missing-file']

if self.test_env.get("keep_going_on_missing_file", False):
args += ['--keep-going-on-missing-file']

# Run the checker
if self.perf_mode:
self.perf_run(args)
else:
self.check_run(args)
# Use `catch_error=False` to avoid failing on non-zero status code,
# as some tests actually exert erroneous behaviors.
self.check_run(args, catch_error=False)

def parse_flagged_lines(self, output: str) -> Flags:
# Compile the pattern to match a checker output
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions testsuite/tests/checks/missing_file_error/test.out
@@ -0,0 +1 @@
ERROR: File p.ads not found
2 changes: 2 additions & 0 deletions testsuite/tests/checks/missing_file_warning/prj.gpr
@@ -0,0 +1,2 @@
project Prj is
end Prj;
9 changes: 9 additions & 0 deletions testsuite/tests/checks/missing_file_warning/q.ads
@@ -0,0 +1,9 @@
with P;

package Q is
type T is range 1 .. 5;

subtype U is T;

X : constant P.T := 2;
end Q;
4 changes: 4 additions & 0 deletions testsuite/tests/checks/missing_file_warning/test.yaml
@@ -0,0 +1,4 @@
driver: 'checker'
rule_name: integer_types_as_enum
project: 'prj.gpr'
keep_going_on_missing_file: true

0 comments on commit 5ec824e

Please sign in to comment.