Skip to content

Commit

Permalink
Fix tests for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gaogaotiantian committed Apr 23, 2024
1 parent 5d63d37 commit 8d4df90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
import subprocess
import sys
import tempfile
import textwrap
import unittest
Expand All @@ -17,7 +18,7 @@ def run_test(self, script, dumppath, commands):
with tempfile.TemporaryDirectory() as tmpdir:
with open(f"{tmpdir}/script.py", "w") as f:
f.write(script)
subprocess.run(normalize_commands(["python", f"{tmpdir}/script.py"]),
subprocess.run(normalize_commands([sys.executable, f"{tmpdir}/script.py"]),
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

process = subprocess.Popen(normalize_commands(["coredumpy", "load", dumppath]),
Expand All @@ -37,7 +38,7 @@ def run_script(self, script, expected_returncode=0):
with tempfile.TemporaryDirectory() as tmpdir:
with open(f"{tmpdir}/script.py", "w") as f:
f.write(script)
process = subprocess.Popen(normalize_commands(["python", f"{tmpdir}/script.py"]),
process = subprocess.Popen(normalize_commands([sys.executable, f"{tmpdir}/script.py"]),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
stdout = stdout.decode()
Expand Down
3 changes: 2 additions & 1 deletion tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@


import os
import sys


def normalize_commands(commands):
if os.getenv("COVERAGE_RUN"):
if commands[0] == "python":
if commands[0] == "python" or commands[0] == sys.executable:
commands = ["coverage", "run", "--parallel-mode"] + commands[1:]
elif commands[0] == "coredumpy":
commands = ["coverage", "run", "--parallel-mode", "-m", "coredumpy"] + commands[1:]
Expand Down

0 comments on commit 8d4df90

Please sign in to comment.