Skip to content

Commit 6e16a34

Browse files
committed
Factorize Alire stub and make it reusable by any test
1 parent 56de27b commit 6e16a34

File tree

13 files changed

+75
-48
lines changed

13 files changed

+75
-48
lines changed

testsuite/ada_lsp/project_config.alire/.alr_printenv

Lines changed: 0 additions & 7 deletions
This file was deleted.

testsuite/ada_lsp/project_config.alire/alr

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
title: 'project_config.alire'
2+
use-alire-stub: True
23
control:
34
- ['SKIP', 'env.build.os.name == "windows"']

testsuite/drivers/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,31 @@ def shell(self, *args, **kwargs) -> ProcessResult:
3838
if self.env.gnatcov:
3939
kwargs = self.env.gnatcov.decorate_run(self, kwargs)
4040

41+
kwargs = self.add_alire_stub(kwargs)
42+
4143
return super().shell(*args, **kwargs)
4244

45+
def add_alire_stub(self, kwargs) -> dict:
46+
"""Optionally add an Alire stub to the environment used for a e3.os.process.Run
47+
call, if the test.yaml sets 'use-alire-stub: True'.
48+
"""
49+
if self.test_env.get("use-alire-stub", False):
50+
kwargs = dict(kwargs)
51+
env = kwargs.setdefault("env", {})
52+
alire_stub = self.alire_stub_path
53+
path = env.get("PATH", os.environ["PATH"])
54+
env["PATH"] = os.pathsep.join([alire_stub, path])
55+
56+
# Default to merging the above env with the parent env
57+
kwargs.setdefault("ignore_environ", False)
58+
59+
return kwargs
60+
61+
@property
62+
def alire_stub_path(self):
63+
"""Path to the Alire stub provided by the testsuite"""
64+
return os.path.join(self.env.root_dir, "shared", "alire-stub")
65+
4366
def run_and_log(self, cmd, **kwargs):
4467
"""
4568
Wrapper around e3.os.process.Run to log processes.
@@ -54,6 +77,8 @@ def run_and_log(self, cmd, **kwargs):
5477
if self.env.gnatcov:
5578
kwargs = self.env.gnatcov.decorate_run(self, kwargs)
5679

80+
kwargs = self.add_alire_stub(kwargs)
81+
5782
process = Run(cmd, **kwargs)
5883

5984
self.result.processes.append(

testsuite/drivers/pylsp.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,10 @@ def assertEqual(self, actual: Any, expected: Any) -> None:
469469
"""Raise an AssertionError if actual != expected."""
470470
assertEqual(actual, expected)
471471

472+
def assertNotEqual(self, actual: Any, expected: Any) -> None:
473+
"""Raise an AssertionError if actual == expected."""
474+
assertNotEqual(actual, expected)
475+
472476
def assertLocationsList(
473477
self,
474478
actual: Sequence[CallHierarchyItem | CallHierarchyIncomingCall],
@@ -905,7 +909,22 @@ def find_ALS_process():
905909
def assertEqual(actual: Any, expected: Any) -> None:
906910
"""Raise an AssertionError if actual != expected."""
907911
if actual != expected:
908-
msg = f"\n### Actual ###\n{actual}\n### Expected ###\n{expected}"
912+
msg = (
913+
"Expected actual == expected"
914+
f"\n### Actual ###\n{actual}"
915+
f"\n### Expected ###\n{expected}"
916+
)
917+
raise AssertionError(msg)
918+
919+
920+
def assertNotEqual(actual: Any, expected: Any) -> None:
921+
"""Raise an AssertionError if actual == expected."""
922+
if actual == expected:
923+
msg = (
924+
"Expected actual != expected"
925+
f"\n### Actual ###\n{actual}"
926+
f"\n### Expected ###\n{expected}"
927+
)
909928
raise AssertionError(msg)
910929

911930

testsuite/gpr_lsp/project_config.alire/.alr_printenv

Lines changed: 0 additions & 7 deletions
This file was deleted.

testsuite/gpr_lsp/project_config.alire/.alr_show

Lines changed: 0 additions & 16 deletions
This file was deleted.

testsuite/gpr_lsp/project_config.alire/alr

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
title: 'project_config.alire'
2+
use-alire-stub: True
23
control:
34
- ['SKIP', 'env.build.os.name not in ("linux")']

0 commit comments

Comments
 (0)