aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-01-02 15:00:53 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-04-03 12:27:07 -0700
commit2b2d075b95cf11480113fefc272b625204e9dc11 (patch)
tree5879d5f8a84e022b1bd14bc2479b2c5ba399543e
parentd332a122c86ab64b644c05242aadc3a668e93e7a (diff)
downloadmeson-2b2d075b95cf11480113fefc272b625204e9dc11.zip
meson-2b2d075b95cf11480113fefc272b625204e9dc11.tar.gz
meson-2b2d075b95cf11480113fefc272b625204e9dc11.tar.bz2
tests: demonstrate that our scanner cannot handle cross target modules
-rw-r--r--test cases/fortran/8 module names/lib.f909
-rw-r--r--test cases/fortran/8 module names/meson.build13
-rw-r--r--test cases/fortran/8 module names/meson_options.txt1
-rw-r--r--test cases/fortran/8 module names/mod2.f908
-rw-r--r--test cases/fortran/8 module names/test.f903
-rw-r--r--unittests/allplatformstests.py22
-rw-r--r--unittests/baseplatformtests.py1
7 files changed, 50 insertions, 7 deletions
diff --git a/test cases/fortran/8 module names/lib.f90 b/test cases/fortran/8 module names/lib.f90
new file mode 100644
index 0000000..f8a8bfd
--- /dev/null
+++ b/test cases/fortran/8 module names/lib.f90
@@ -0,0 +1,9 @@
+program lib
+use MyMod1
+use MyMod2 ! test inline comment
+
+implicit none
+
+call showvalues()
+
+end program
diff --git a/test cases/fortran/8 module names/meson.build b/test cases/fortran/8 module names/meson.build
index 632c597..9340c79 100644
--- a/test cases/fortran/8 module names/meson.build
+++ b/test cases/fortran/8 module names/meson.build
@@ -1,6 +1,15 @@
+# SPDX-License-Identifier: Apache-2.0
+# Copyright © 2024 Intel Corporation
+
project('mod_name_case', 'fortran')
sources = ['test.f90', 'mod1.f90', 'mod2.f90']
-exe = executable('mod_name_case', sources)
-test('mod_name_case', exe)
+l = static_library('s1', 'mod1.f90')
+l2 = static_library('s2', 'mod2.f90', link_whole : l)
+if get_option('unittest')
+ sh = static_library('library', 'lib.f90', link_with : l2)
+else
+ exe = executable('mod_name_case', 'test.f90', link_with : l2)
+ test('mod_name_case', exe)
+endif
diff --git a/test cases/fortran/8 module names/meson_options.txt b/test cases/fortran/8 module names/meson_options.txt
new file mode 100644
index 0000000..b5b7ee9
--- /dev/null
+++ b/test cases/fortran/8 module names/meson_options.txt
@@ -0,0 +1 @@
+option('unittest', type : 'boolean', value : false)
diff --git a/test cases/fortran/8 module names/mod2.f90 b/test cases/fortran/8 module names/mod2.f90
index 2087750..3061c21 100644
--- a/test cases/fortran/8 module names/mod2.f90
+++ b/test cases/fortran/8 module names/mod2.f90
@@ -1,6 +1,14 @@
module mymod2
+use mymod1
implicit none
integer, parameter :: myModVal2 = 2
+contains
+ subroutine showvalues()
+ print*, "myModVal1 = ", myModVal1
+ print*, "myModVal2 = ", myModVal2
+ end subroutine showvalues
+
+
end module mymod2
diff --git a/test cases/fortran/8 module names/test.f90 b/test cases/fortran/8 module names/test.f90
index 60ff16e..fcfc23f 100644
--- a/test cases/fortran/8 module names/test.f90
+++ b/test cases/fortran/8 module names/test.f90
@@ -1,9 +1,8 @@
program main
-use mymod1
use MyMod2 ! test inline comment
implicit none
-integer, parameter :: testVar = myModVal1 + myModVal2
+call showvalues()
end program
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index a189065..34bdf86 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2016-2021 The Meson development team
-# Copyright © 2023-2024 Intel Corporation
+# Copyright © 2023-2025 Intel Corporation
import subprocess
import re
@@ -13,7 +13,7 @@ import platform
import pickle
import zipfile, tarfile
import sys
-from unittest import mock, SkipTest, skipIf, skipUnless
+from unittest import mock, SkipTest, skipIf, skipUnless, expectedFailure
from contextlib import contextmanager
from glob import glob
from pathlib import (PurePath, Path)
@@ -33,7 +33,7 @@ from mesonbuild.mesonlib import (
is_sunos, windows_proof_rmtree, python_command, version_compare, split_args, quote_arg,
relpath, is_linux, git, search_version, do_conf_file, do_conf_str, default_prefix,
MesonException, EnvironmentException,
- windows_proof_rm
+ windows_proof_rm, first
)
from mesonbuild.options import OptionKey
from mesonbuild.programs import ExternalProgram
@@ -5208,3 +5208,19 @@ class AllPlatformTests(BasePlatformTests):
self.assertRegex(output, r'Ok:\s*0')
self.assertRegex(output, r'Fail:\s*0')
self.assertRegex(output, r'Ignored:\s*1')
+
+ @expectedFailure
+ @skip_if_not_language('fortran')
+ def test_fortran_cross_target_module_dep(self) -> None:
+ if self.backend is not Backend.ninja:
+ raise SkipTest('Test is only relavent on the ninja backend')
+ testdir = os.path.join(self.fortran_test_dir, '8 module names')
+ self.init(testdir, extra_args=['-Dunittest=true'])
+
+ # Find the correct output to compile, regardless of what compiler is being used
+ comp = self.get_compdb()
+ entry = first(comp, lambda e: e['file'].endswith('lib.f90'))
+ assert entry is not None, 'for mypy'
+ output = entry['output']
+
+ self.build(output, extra_args=['-j1'])
diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py
index 5fff212..f9bb581 100644
--- a/unittests/baseplatformtests.py
+++ b/unittests/baseplatformtests.py
@@ -78,6 +78,7 @@ class BasePlatformTests(TestCase):
cls.objc_test_dir = os.path.join(src_root, 'test cases/objc')
cls.objcpp_test_dir = os.path.join(src_root, 'test cases/objcpp')
cls.darwin_test_dir = os.path.join(src_root, 'test cases/darwin')
+ cls.fortran_test_dir = os.path.join(src_root, 'test cases/fortran')
# Misc stuff
if cls.backend is Backend.ninja: