Skip to content

Commit 69fc936

Browse files
drinkcatsylvestre
authored andcommitted
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.
1 parent bdf2333 commit 69fc936

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/uutests/src/lib/util.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,17 @@ impl TestScenario {
13591359
command
13601360
}
13611361

1362+
/// Returns builder for invoking a command in shell (e.g. sh -c 'cmd').
1363+
/// Paths given are treated relative to the environment's unique temporary
1364+
/// test directory.
1365+
pub fn cmd_shell<S: AsRef<OsStr>>(&self, cmd: S) -> UCommand {
1366+
let mut command = UCommand::new();
1367+
// Intentionally leave bin_path unset.
1368+
command.arg(cmd);
1369+
command.temp_dir(self.tmpd.clone());
1370+
command
1371+
}
1372+
13621373
/// Returns builder for invoking any uutils command. Paths given are treated
13631374
/// relative to the environment's unique temporary test directory.
13641375
pub fn ccmd<S: AsRef<str>>(&self, util_name: S) -> UCommand {
@@ -3534,8 +3545,7 @@ mod tests {
35343545
};
35353546

35363547
let ts = TestScenario::new("util");
3537-
ts.cmd("sh")
3538-
.args(&["-c", "umask"])
3548+
ts.cmd_shell("umask")
35393549
.umask(c_umask)
35403550
.succeeds()
35413551
.stdout_is(expected);

0 commit comments

Comments
 (0)