Skip to content

Commit

Permalink
Merge branch 'topic/gnatcheck_worker_errors' into 'master'
Browse files Browse the repository at this point in the history
Correct gnatcheck_errors tests

Closes #177

See merge request eng/libadalang/langkit-query-language!147
  • Loading branch information
HugoGGuerrier committed Nov 24, 2023
2 parents 2a85c15 + 8d0d239 commit 32de4d0
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 16 deletions.
3 changes: 2 additions & 1 deletion testsuite/drivers/base_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def baseline(self) -> tuple[str, str, bool]:
@property
def test_control_creator(self):
return YAMLTestControlCreator({
'mode': self.env.options.mode
'mode': self.env.options.mode,
'os': self.env.build.os.name,
})

def set_up(self) -> None:
Expand Down
13 changes: 13 additions & 0 deletions testsuite/drivers/gnatcheck_driver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import os.path as P
import re
import sys
import xml.etree.ElementTree as ET

from e3.testsuite.driver.diff import (
Expand Down Expand Up @@ -173,7 +174,19 @@ def run(self) -> None:
gnatcheck_env["LKQL_RULES_PATH"] = getattr(
self.env, "gnatcheck_rules_path", ""
)

# Get the test provided custom GNATcheck worker
custom_worker = self.test_env.get('worker', None)

# Special case if the provided worker is "unparsable_generator" then
# we call the lkql_jit.py script in a special mode.
if custom_worker == "unparsable_generator":
custom_worker = " ".join([
sys.executable,
P.join(self.env.support_dir, "lkql_jit.py"),
"unparsable_generator"
])

gnatcheck_env["GNATCHECK_WORKER"] = custom_worker or " ".join(
self.gnatcheck_worker_exe
)
Expand Down
21 changes: 17 additions & 4 deletions testsuite/python_support/lkql_jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,31 @@ def get_java_command(entry_point: str) -> list[str]:
f'com.adacore.lkql_jit.{main_classes[entry_point]}'
]

def print_gnatcheck_unparsable():
print("This line is not parsable")
print("Message: should appear")
print("no_a_file.adb:01:01: Message: Should not appear")
print("This line is not parsable either")

if __name__ == '__main__':
# Create the script argument parser
parser = argparse.ArgumentParser(prog="lkql_jit.py",
description=__doc__)
subparsers = parser.add_subparsers(help="LKQL JIT entry point", required=True)
for subcommand, help in [
("lkql", "Main entry point for LKQL")
("lkql", "Main entry point for LKQL"),
(
"unparsable_generator",
"Entry point to generate unparsable GNATcheck messages"
)
]:
subp = subparsers.add_parser(subcommand, help=help)
subp.set_defaults(subc=subcommand)

args, to_forward = parser.parse_known_args()
command = get_java_command(args.subc)
command.extend(to_forward)
subprocess.run(command)
if args.subc == "unparsable_generator":
print_gnatcheck_unparsable()
else:
command = get_java_command(args.subc)
command.extend(to_forward)
subprocess.run(command)
3 changes: 0 additions & 3 deletions testsuite/tests/gnatcheck_errors/invalid_worker/test.out

This file was deleted.

7 changes: 0 additions & 7 deletions testsuite/tests/gnatcheck_errors/invalid_worker/test.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
driver: gnatcheck
format: brief
project: prj.gpr
rules:
- +RGOTO_Statements
control:
- [SKIP,
"os == 'windows'",
"Disable this test on Windows due to path formatting"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project Prj is
for Source_Dirs use ("invalid_source_dirs");
end Prj;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gnatcheck: prj.gpr:2:26: error: "\invalid_source_dirs" is not a valid directory
gnatcheck: prj.gpr: warning: there are no sources of language "Ada" in this project
try "gnatcheck --help" for more information.
>>>program returned status code 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
driver: gnatcheck
format: brief
project: prj.gpr
rules:
- +RGOTO_Statements
control:
- [SKIP,
"os != 'windows'",
"Disable this test on non-Windows systems due to path formatting"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gnatcheck: Unparsable line: This line is not parsable
gnatcheck: Unparsable line: Message: should appear
gnatcheck: Unparsable line: This line is not parsable either
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
driver: gnatcheck
format: brief
project: prj.gpr
worker: "unparsable_generator"
input_sources:
- main.adb
rules:
- +RGOTO_Statements

0 comments on commit 32de4d0

Please sign in to comment.