Skip to content

Commit f7bd70d

Browse files
authored
Merge pull request #987 from onekey-sec/fix-test-command-devenv-old-libc
fix(test): when run under old systems in devenv
2 parents c8c32ea + aeb53ce commit f7bd70d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/extractors/test_command.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ def test_command_templating_with_invalid_substitution(template):
3434

3535
def test_command_execution(tmpdir: Path):
3636
outdir = PosixPath(tmpdir)
37-
command = Command("sh", "-c", "> {outdir}/created")
37+
# fmt: off
38+
command = Command(
39+
"python",
40+
"-c",
41+
"import pathlib\n"
42+
"pathlib.Path('{outdir}/created').touch()",
43+
)
44+
# fmt: on
3845

3946
command.extract(Path("foo"), outdir)
4047

@@ -43,7 +50,14 @@ def test_command_execution(tmpdir: Path):
4350

4451
def test_command_execution_failure(tmpdir: Path):
4552
outdir = PosixPath(tmpdir)
46-
command = Command("sh", "-c", ">&1 echo -n stdout; >&2 echo -n stderr; false")
53+
command = Command(
54+
"python",
55+
"-c",
56+
"import sys\n"
57+
"sys.stdout.write('stdout')\n"
58+
"sys.stderr.write('stderr')\n"
59+
"sys.exit(1)",
60+
)
4761

4862
with pytest.raises(ExtractError) as excinfo:
4963
command.extract(Path("input"), outdir)

0 commit comments

Comments
 (0)