mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 11:03:07 -04:00
rust: rust_is_available: support testing with bash as /bin/sh
`command -v` behaves differently on `dash` vs. `bash` when faced with a file without the execute bit. Thus, for the non-executable `rustc` and `bindgen` tests, support both possible outputs that the script currently gives. This makes the test script clean on distributions like Fedora. Reviewed-by: Onur Özkan <work@onurozkan.dev> Link: https://patch.msgid.link/20260719130723.162899-1-ojeda@kernel.org [ Added custom assertion message as suggested. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
@@ -177,7 +177,13 @@ else:
|
||||
|
||||
def test_rustc_nonexecutable(self):
|
||||
result = self.run_script(self.Expected.FAILURE, { "RUSTC": self.nonexecutable })
|
||||
self.assertIn(f"Running '{self.nonexecutable}' to check the Rust compiler version failed with", result.stderr)
|
||||
self.assertTrue(
|
||||
# `dash`.
|
||||
f"Running '{self.nonexecutable}' to check the Rust compiler version failed with" in result.stderr or
|
||||
# `bash`.
|
||||
f"Rust compiler '{self.nonexecutable}' could not be found." in result.stderr,
|
||||
f"Unexpected `stderr`:\n{result.stderr}"
|
||||
)
|
||||
|
||||
def test_rustc_unexpected_binary(self):
|
||||
result = self.run_script(self.Expected.FAILURE, { "RUSTC": self.unexpected_binary })
|
||||
@@ -205,7 +211,13 @@ else:
|
||||
|
||||
def test_bindgen_nonexecutable(self):
|
||||
result = self.run_script(self.Expected.FAILURE, { "BINDGEN": self.nonexecutable })
|
||||
self.assertIn(f"Running '{self.nonexecutable}' to check the Rust bindings generator version failed with", result.stderr)
|
||||
self.assertTrue(
|
||||
# `dash`.
|
||||
f"Running '{self.nonexecutable}' to check the Rust bindings generator version failed with" in result.stderr or
|
||||
# `bash`.
|
||||
f"Rust bindings generator '{self.nonexecutable}' could not be found." in result.stderr,
|
||||
f"Unexpected `stderr`:\n{result.stderr}"
|
||||
)
|
||||
|
||||
def test_bindgen_unexpected_binary(self):
|
||||
result = self.run_script(self.Expected.FAILURE, { "BINDGEN": self.unexpected_binary })
|
||||
|
||||
Reference in New Issue
Block a user