diff --git a/testsuite/drivers/base_driver.py b/testsuite/drivers/base_driver.py index c95e5ad2c..cb4896690 100644 --- a/testsuite/drivers/base_driver.py +++ b/testsuite/drivers/base_driver.py @@ -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: diff --git a/testsuite/drivers/gnatcheck_driver.py b/testsuite/drivers/gnatcheck_driver.py index e6eda25bb..751d18eb4 100644 --- a/testsuite/drivers/gnatcheck_driver.py +++ b/testsuite/drivers/gnatcheck_driver.py @@ -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 ( @@ -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 ) diff --git a/testsuite/python_support/lkql_jit.py b/testsuite/python_support/lkql_jit.py index 20f45ed0e..1176f6522 100644 --- a/testsuite/python_support/lkql_jit.py +++ b/testsuite/python_support/lkql_jit.py @@ -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) diff --git a/testsuite/tests/gnatcheck_errors/invalid_worker/test.out b/testsuite/tests/gnatcheck_errors/invalid_worker/test.out deleted file mode 100644 index ad5cd3fb7..000000000 --- a/testsuite/tests/gnatcheck_errors/invalid_worker/test.out +++ /dev/null @@ -1,3 +0,0 @@ -gnatcheck: Unparsable line: Not a message -gnatcheck: Unparsable line: Message: Should appear -gnatcheck: Unparsable line: --files-from=/gnatcheck-files1.TMP --rules-from=/gnatcheck-rules0.TMP diff --git a/testsuite/tests/gnatcheck_errors/invalid_worker/test.yaml b/testsuite/tests/gnatcheck_errors/invalid_worker/test.yaml deleted file mode 100644 index 5c8444b92..000000000 --- a/testsuite/tests/gnatcheck_errors/invalid_worker/test.yaml +++ /dev/null @@ -1,7 +0,0 @@ -driver: gnatcheck -format: brief -worker: "echo Not a message\nnot_a_file.adb:01:01: Should not appear\nMessage: Should appear\n" -input_sources: - - main.adb -rules: - - +RGOTO_Statements diff --git a/testsuite/tests/gnatcheck_errors/missing_source_dirs/prj.gpr b/testsuite/tests/gnatcheck_errors/missing_source_dirs/linux/prj.gpr similarity index 100% rename from testsuite/tests/gnatcheck_errors/missing_source_dirs/prj.gpr rename to testsuite/tests/gnatcheck_errors/missing_source_dirs/linux/prj.gpr diff --git a/testsuite/tests/gnatcheck_errors/missing_source_dirs/test.out b/testsuite/tests/gnatcheck_errors/missing_source_dirs/linux/test.out similarity index 100% rename from testsuite/tests/gnatcheck_errors/missing_source_dirs/test.out rename to testsuite/tests/gnatcheck_errors/missing_source_dirs/linux/test.out diff --git a/testsuite/tests/gnatcheck_errors/missing_source_dirs/linux/test.yaml b/testsuite/tests/gnatcheck_errors/missing_source_dirs/linux/test.yaml new file mode 100644 index 000000000..8767e7adc --- /dev/null +++ b/testsuite/tests/gnatcheck_errors/missing_source_dirs/linux/test.yaml @@ -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"] diff --git a/testsuite/tests/gnatcheck_errors/missing_source_dirs/windows/prj.gpr b/testsuite/tests/gnatcheck_errors/missing_source_dirs/windows/prj.gpr new file mode 100644 index 000000000..a6fe033af --- /dev/null +++ b/testsuite/tests/gnatcheck_errors/missing_source_dirs/windows/prj.gpr @@ -0,0 +1,3 @@ +project Prj is + for Source_Dirs use ("invalid_source_dirs"); +end Prj; diff --git a/testsuite/tests/gnatcheck_errors/missing_source_dirs/windows/test.out b/testsuite/tests/gnatcheck_errors/missing_source_dirs/windows/test.out new file mode 100644 index 000000000..f86df2c1c --- /dev/null +++ b/testsuite/tests/gnatcheck_errors/missing_source_dirs/windows/test.out @@ -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 diff --git a/testsuite/tests/gnatcheck_errors/missing_source_dirs/windows/test.yaml b/testsuite/tests/gnatcheck_errors/missing_source_dirs/windows/test.yaml new file mode 100644 index 000000000..2b232a09a --- /dev/null +++ b/testsuite/tests/gnatcheck_errors/missing_source_dirs/windows/test.yaml @@ -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"] diff --git a/testsuite/tests/gnatcheck_errors/invalid_worker/main.adb b/testsuite/tests/gnatcheck_errors/unparsable_worker_messages/main.adb similarity index 100% rename from testsuite/tests/gnatcheck_errors/invalid_worker/main.adb rename to testsuite/tests/gnatcheck_errors/unparsable_worker_messages/main.adb diff --git a/testsuite/tests/gnatcheck_errors/unparsable_worker_messages/test.out b/testsuite/tests/gnatcheck_errors/unparsable_worker_messages/test.out new file mode 100644 index 000000000..6b5dbdc2d --- /dev/null +++ b/testsuite/tests/gnatcheck_errors/unparsable_worker_messages/test.out @@ -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 diff --git a/testsuite/tests/gnatcheck_errors/missing_source_dirs/test.yaml b/testsuite/tests/gnatcheck_errors/unparsable_worker_messages/test.yaml similarity index 50% rename from testsuite/tests/gnatcheck_errors/missing_source_dirs/test.yaml rename to testsuite/tests/gnatcheck_errors/unparsable_worker_messages/test.yaml index dd920e401..b3f3b9779 100644 --- a/testsuite/tests/gnatcheck_errors/missing_source_dirs/test.yaml +++ b/testsuite/tests/gnatcheck_errors/unparsable_worker_messages/test.yaml @@ -1,5 +1,7 @@ driver: gnatcheck format: brief -project: prj.gpr +worker: "unparsable_generator" +input_sources: + - main.adb rules: - +RGOTO_Statements