From 152dada37992964a9913a7e49add26878c0c8ad1 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sun, 23 Mar 2025 17:35:52 +0100 Subject: [PATCH] tests/common/util: Make sure test_altering_umask is run in correct shell On Android CI, `sh` would point at a different flavor of shell shipped with termux (dash). The current umask test expects that `/system/bin/sh` is used though, so create a new function TestScenario:cmd_shell that runs a command in the default shell (that could be used in more tests). Fixes one part of #7542. --- tests/common/util.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/common/util.rs b/tests/common/util.rs index 79b3a5de1..1a4717170 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -1215,6 +1215,17 @@ impl TestScenario { command } + /// Returns builder for invoking a command in shell (e.g. sh -c 'cmd'). + /// Paths given are treated relative to the environment's unique temporary + /// test directory. + pub fn cmd_shell>(&self, cmd: S) -> UCommand { + let mut command = UCommand::new(); + // Intentionally leave bin_path unset. + command.arg(cmd); + command.temp_dir(self.tmpd.clone()); + command + } + /// Returns builder for invoking any uutils command. Paths given are treated /// relative to the environment's unique temporary test directory. pub fn ccmd>(&self, util_name: S) -> UCommand { @@ -4052,8 +4063,7 @@ mod tests { }; let ts = TestScenario::new("util"); - ts.cmd("sh") - .args(&["-c", "umask"]) + ts.cmd_shell("umask") .umask(c_umask) .succeeds() .stdout_is(expected);