Skip to content

Commit

Permalink
Merge pull request #987 from onekey-sec/fix-test-command-devenv-old-libc
Browse files Browse the repository at this point in the history
fix(test): when run under old systems in devenv
  • Loading branch information
e3krisztian authored Oct 21, 2024
2 parents c8c32ea + aeb53ce commit f7bd70d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/extractors/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ def test_command_templating_with_invalid_substitution(template):

def test_command_execution(tmpdir: Path):
outdir = PosixPath(tmpdir)
command = Command("sh", "-c", "> {outdir}/created")
# fmt: off
command = Command(
"python",
"-c",
"import pathlib\n"
"pathlib.Path('{outdir}/created').touch()",
)
# fmt: on

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

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

def test_command_execution_failure(tmpdir: Path):
outdir = PosixPath(tmpdir)
command = Command("sh", "-c", ">&1 echo -n stdout; >&2 echo -n stderr; false")
command = Command(
"python",
"-c",
"import sys\n"
"sys.stdout.write('stdout')\n"
"sys.stderr.write('stderr')\n"
"sys.exit(1)",
)

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

0 comments on commit f7bd70d

Please sign in to comment.