AdaCore / libadalang

Ada semantic analysis library.
https://www.adacore.com
Other
147 stars 42 forks source link

Tests fail in release mode due to build mode not being passed through #955

Closed LordAro closed 1 year ago

LordAro commented 1 year ago

There's a few tests that fail when libadalang & friends are built in prod mode:

INFO     FAIL            contrib__highlight: python3.8 returned status code 1 (0 expected)
INFO     FAIL            misc__copyright: python3.8 returned status code 1 (0 expected)
INFO     FAIL            dsl_unparse: /builds/dev/libadalang/venv/bin/python3.8 returned status code 1 (0 expected)

All of which are failing due to looking for binaries/etc in the wrong folder (dev instead of prod). e.g.:

FileNotFoundError: [Errno 2] No such file or directory: 'libadalang.gpr:53:32: warning: object directory "obj/dev" not found'

Here's my patch for fixing this (can PR if you want, but I don't think you use them from the GH side?) : Reexports the driver's build_mode into an environment variable, which is then inserted as appropriate into the relevant tests.

diff --git a/testsuite/drivers/python_driver.py b/testsuite/drivers/python_driver.py
index 79668561..3446e469 100644
--- a/testsuite/drivers/python_driver.py
+++ b/testsuite/drivers/python_driver.py
@@ -82,7 +82,8 @@ class PythonRunner(object):
                 ),
                 'LIBADALANG_DISABLE_SHARED': str(
                     int(self.driver.disable_shared)
-                )
+                ),
+                'LIBADALANG_BUILD_MODE': self.driver.build_mode,
             }
         )

diff --git a/testsuite/python_support/utils.py b/testsuite/python_support/utils.py
index 33e935db..681016d9 100644
--- a/testsuite/python_support/utils.py
+++ b/testsuite/python_support/utils.py
@@ -7,6 +7,7 @@ import subprocess

 LAL_ROOTDIR = os.path.abspath(os.environ['LIBADALANG_ROOTDIR'])
 LAL_DISABLE_SHARED = bool(int(os.environ['LIBADALANG_DISABLE_SHARED']))
+LAL_BUILD_MODE = os.environ['LIBADALANG_BUILD_MODE'] or "dev"

 DIRECTORY_MISSING_RE = re.compile(
     r'.*\.gpr:\d+:\d+: warning:'
@@ -20,6 +21,7 @@ LIBRARY_KIND = 'static' if LAL_DISABLE_SHARED else 'relocatable'
 GPR_ARGS = [
     '-XLIBRARY_TYPE={}'.format(LIBRARY_KIND),
     '-XXMLADA_BUILD={}'.format(LIBRARY_KIND),
+    '-XBUILD_MODE={}'.format(LAL_BUILD_MODE),

     # Make sure GPRbuild does not try to rebuild Libadalang, as this will break
     # other tests running in parallel.
diff --git a/testsuite/tests/dsl_unparse/test.py b/testsuite/tests/dsl_unparse/test.py
index 3b462667..b11df3a6 100644
--- a/testsuite/tests/dsl_unparse/test.py
+++ b/testsuite/tests/dsl_unparse/test.py
@@ -37,6 +37,8 @@ except StopIteration:
         unparse_dest
     ))

+LAL_BUILD_MODE = os.environ['LIBADALANG_BUILD_MODE'] or "dev"
+
 sys.stdout.flush()
 subprocess.check_call(
     [
@@ -47,7 +49,7 @@ subprocess.check_call(
             'lkt',
             'build',
             'obj-mains',
-            'dev',
+            LAL_BUILD_MODE,
             'lkt_parse',
         ),
         '-s',
pmderodat commented 1 year ago

Hello,

Thank you for this contribution!

Even though we indeed can’t use the GitHub merge feature anymore, a PR would be nicer: it helps us make sure we’re good wrt the CLA and having a ready-to-cherry-pick commit allows us to preserve credits to your work. ;-) Plus a PR still makes code review more convenient.