aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-09-25 14:42:12 +0300
committerGitHub <noreply@github.com>2021-09-25 14:42:12 +0300
commitf6ae82169cd3780d2c9cd0cae7edfea8c427ef35 (patch)
treec5134832db2202f3c273ff6575a23b5464e0a3fe /unittests
parentc0efa7ab22f8900f6fa1dadf0d306ec375569c8d (diff)
parent30202a24021587b7d7ddffd8312eb5b425b3e273 (diff)
downloadmeson-f6ae82169cd3780d2c9cd0cae7edfea8c427ef35.zip
meson-f6ae82169cd3780d2c9cd0cae7edfea8c427ef35.tar.gz
meson-f6ae82169cd3780d2c9cd0cae7edfea8c427ef35.tar.bz2
Merge pull request #8773 from dcbaker/submit/rustc-enhancements-clippy
More enhancements for Rust + clippy support
Diffstat (limited to 'unittests')
-rw-r--r--unittests/allplatformstests.py13
-rw-r--r--unittests/baseplatformtests.py5
2 files changed, 16 insertions, 2 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 7afa989..93a2e49 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -4034,3 +4034,16 @@ class AllPlatformTests(BasePlatformTests):
for file, details in files.items():
with self.subTest(key='{}.{}'.format(data_type, file)):
self.assertEqual(res[data_type][file], details)
+
+ @skip_if_not_language('rust')
+ @unittest.skipIf(not shutil.which('clippy-driver'), 'Test requires clippy-driver')
+ def test_rust_clippy(self) -> None:
+ if self.backend is not Backend.ninja:
+ raise unittest.SkipTest('Rust is only supported with ninja currently')
+ # Wehn clippy is used, we should get an exception since a variable named
+ # "foo" is used, but is on our denylist
+ testdir = os.path.join(self.rust_test_dir, '1 basic')
+ self.init(testdir, extra_args=['--werror'], override_envvars={'RUSTC': 'clippy-driver'})
+ with self.assertRaises(subprocess.CalledProcessError) as cm:
+ self.build()
+ self.assertIn('error: use of a blacklisted/placeholder name `foo`', cm.exception.stdout)
diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py
index 3492785..9371395 100644
--- a/unittests/baseplatformtests.py
+++ b/unittests/baseplatformtests.py
@@ -69,6 +69,7 @@ class BasePlatformTests(TestCase):
self.uninstall_command = get_backend_commands(self.backend)
# Test directories
self.common_test_dir = os.path.join(src_root, 'test cases/common')
+ self.rust_test_dir = os.path.join(src_root, 'test cases/rust')
self.vala_test_dir = os.path.join(src_root, 'test cases/vala')
self.framework_test_dir = os.path.join(src_root, 'test cases/frameworks')
self.unit_test_dir = os.path.join(src_root, 'test cases/unit')
@@ -135,7 +136,7 @@ class BasePlatformTests(TestCase):
os.environ.update(self.orig_env)
super().tearDown()
- def _run(self, command, *, workdir=None, override_envvars=None):
+ def _run(self, command, *, workdir=None, override_envvars: T.Optional[T.Mapping[str, str]] = None):
'''
Run a command while printing the stdout and stderr to stdout,
and also return a copy of it
@@ -164,7 +165,7 @@ class BasePlatformTests(TestCase):
extra_args=None,
default_args=True,
inprocess=False,
- override_envvars=None,
+ override_envvars: T.Optional[T.Mapping[str, str]] = None,
workdir=None,
allow_fail: bool = False) -> str:
"""Call `meson setup`