Repository: mesonbuild/meson

Issue:
Test suite fails with Rust v1.65.0
The 0.63.0 test suite (`./run_tests.py --failfast`) fails on Arch Linux since the upgrade to Rust v1.65.0. It seems the Clippy error message got changed from

```
error: use of a blacklisted/placeholder name `foo`
```

to

```
error: use of a disallowed/placeholder name `foo`
```

Failure log:
```
=================================== FAILURES ===================================
______________________ AllPlatformTests.test_rust_clippy _______________________
[gw61] linux -- Python 3.10.8 /usr/bin/python3

self = <unittests.allplatformstests.AllPlatformTests testMethod=test_rust_clippy>

    @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')
        # When 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)
E       AssertionError: 'error: use of a blacklisted/placeholder name `foo`' not found in 'ninja explain: deps for \'rust-program\' are missing\nninja explain: rust-program is dirty\nninja explain: deps for \'subdir/rust-program2\' are missing\nninja explain: subdir/rust-program2 is dirty\nninja explain: meson-test-prereq is dirty\nninja explain: output meson-benchmark-prereq of phony edge with no inputs doesn\'t exist\nninja explain: meson-benchmark-prereq is dirty\nninja explain: rust-program is dirty\nninja explain: subdir/rust-program2 is dirty\n[1/2] Compiling Rust source \'../test cases/rust/1 basic/prog.rs\'\nFAILED: rust-program \nclippy-driver -C linker=cc --color=always --crate-type bin -D warnings -g --crate-name rust_program --emit dep-info=rust-program.d --emit link -C lto -o rust-program \'../test cases/rust/1 basic/prog.rs\'\nerror: use of a disallowed/placeholder name `foo`\n --> ../test cases/rust/1 basic/prog.rs:2:9\n  |\n2 |     let foo = "rust compiler is working";\n  |         ^^^\n  |\n  = note: `-D clippy::disallowed-names` implied by `-D warnings`\n  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names\n\nerror: aborting due to previous error\n\n[2/2] Compiling Rust source \'../test cases/rust/1 basic/subdir/prog.rs\'\nninja: build stopped: subcommand failed.\n'

unittests/allplatformstests.py:4350: AssertionError
----------------------------- Captured stdout call -----------------------------
$ /usr/bin/python3 /build/meson/src/meson-0.64.0rc2/meson.py setup --backend=ninja '/build/meson/src/meson-0.64.0rc2/test cases/rust/1 basic' /build/meson/src/meson-0.64.0rc2/tmpe6s94o2v --prefix /usr --libdir lib --werror
stdout:
The Meson build system
Version: 0.64.0.rc2
Source dir: /build/meson/src/meson-0.64.0rc2/test cases/rust/1 basic
Build dir: /build/meson/src/meson-0.64.0rc2/tmpe6s94o2v
Build type: native build
Project name: rustprog
Project version: undefined
Rust compiler for the host machine: clippy-driver -C linker=cc (clippy-driver rustc 0.1.65)
Rust linker for the host machine: clippy-driver -C linker=cc ld.bfd 2.39.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 2

rustprog undefined

  User defined options
    backend: ninja
    libdir : lib
    prefix : /usr
    werror : True

Found ninja-1.11.1 at /usr/bin/ninja

$ /usr/bin/ninja -w dupbuild=err -d explain
stdout:
ninja explain: deps for 'rust-program' are missing
ninja explain: rust-program is dirty
ninja explain: deps for 'subdir/rust-program2' are missing
ninja explain: subdir/rust-program2 is dirty
ninja explain: meson-test-prereq is dirty
ninja explain: output meson-benchmark-prereq of phony edge with no inputs doesn't exist
ninja explain: meson-benchmark-prereq is dirty
ninja explain: rust-program is dirty
ninja explain: subdir/rust-program2 is dirty
[1/2] Compiling Rust source '../test cases/rust/1 basic/prog.rs'
FAILED: rust-program 
clippy-driver -C linker=cc --color=always --crate-type bin -D warnings -g --crate-name rust_program --emit dep-info=rust-program.d --emit link -C lto -o rust-program '../test cases/rust/1 basic/prog.rs'
error: use of a disallowed/placeholder name `foo`
 --> ../test cases/rust/1 basic/prog.rs:2:9
  |
2 |     let foo = "rust compiler is working";
  |         ^^^
  |
  = note: `-D clippy::disallowed-names` implied by `-D warnings`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names

error: aborting due to previous error

[2/2] Compiling Rust source '../test cases/rust/1 basic/subdir/prog.rs'
ninja: build stopped: subcommand failed.

=============================== warnings summary ===============================
run_unittests.py::AllPlatformTests::test_pkg_config_libdir
  /build/meson/src/meson-0.64.0rc2/unittests/allplatformstests.py:2543: EncodingWarning: 'encoding' argument not specified
    with tempfile.NamedTemporaryFile(mode='w', delete=False) as crossfile:

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED run_unittests.py::AllPlatformTests::test_rust_clippy - AssertionError:...
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 1 failures !!!!!!!!!!!!!
============= 1 failed, 65 passed, 17 skipped, 1 warning in 10.71s =============
Meson build system 0.64.0.rc2 Unit Tests
Total time: 11.012 seconds
```


Discussion:
Would you submit a PR :)? Thanks for finding it.

Resolving patch:
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -4352,7 +4352,8 @@ def test_rust_clippy(self) -> None:
         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)
+        self.assertTrue('error: use of a blacklisted/placeholder name `foo`' in cm.exception.stdout or
+                        'error: use of a disallowed/placeholder name `foo`' in cm.exception.stdout)
 
     @skip_if_not_language('rust')
     def test_rust_rlib_linkage(self) -> None:


Test patch: