aboutsummaryrefslogtreecommitdiff
path: root/unittests/allplatformstests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-05-17 10:42:57 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-09-24 18:48:48 -0700
commit30202a24021587b7d7ddffd8312eb5b425b3e273 (patch)
tree8b03d4b62f0b35a520f8f5ef859df7156cd62395 /unittests/allplatformstests.py
parentf0a7b6e7c6bf97b22f3e5f1d600717ac7ba4162f (diff)
downloadmeson-30202a24021587b7d7ddffd8312eb5b425b3e273.zip
meson-30202a24021587b7d7ddffd8312eb5b425b3e273.tar.gz
meson-30202a24021587b7d7ddffd8312eb5b425b3e273.tar.bz2
compilers/rust: Add support for clippy
Clippy is a compiler wrapper for rust that provides an extra layer of linting. It's quite popular, but unfortunately doesn't provide the output of the compiler that it's wrapping in it's output, so we don't detect that clippy is rustc. This small patch adds a new compiler class (that is the Rustc class with a different id) and the necessary logic to detect that clippy is in fact rustc) Fixes: #8767
Diffstat (limited to 'unittests/allplatformstests.py')
-rw-r--r--unittests/allplatformstests.py13
1 files changed, 13 insertions, 0 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)