Skip to content

Commit eb2ed22

Browse files
author
Zhen Li
committed
Fixed a few bugs in runtests.py for running python commands on windows
To run runtests.py on windows, we need to add python.exe to windows PATH var To run with different python versions, one way to do it is to update PATH var before calling runtests.py
1 parent 98066c2 commit eb2ed22

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

neokit

Submodule neokit updated 1 file

runtests.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
is_windows = (name == 'nt')
4646

4747

48+
def runpymodule(command):
49+
commands = command.split()
50+
if is_windows:
51+
commands = ['powershell.exe', 'python', '-m'] + commands
52+
return run0(commands)
53+
54+
4855
def runcommand(command):
4956
commands = command.split()
5057
return runcommands(commands)
@@ -88,7 +95,7 @@ def main():
8895

8996
stdout.write("Using python version:\n")
9097
runcommand('python --version')
91-
runcommand('pip install --upgrade -r ./test_requirements.txt')
98+
runpymodule('pip install --upgrade -r ./test_requirements.txt')
9299
retcode = 0
93100

94101
register(neorun, '--stop=' + NEO4J_HOME)
@@ -106,16 +113,16 @@ def main():
106113
retcode = 2
107114

108115
elif opt == "--tests":
109-
retcode = retcode or runcommand(UNITTEST_RUNNER + "test")
116+
retcode = retcode or runpymodule(UNITTEST_RUNNER + "test")
110117
elif opt == "--test=":
111-
retcode = retcode or runcommand(UNITTEST_RUNNER + arg)
118+
retcode = retcode or runpymodule(UNITTEST_RUNNER + arg)
112119
elif opt == "--example":
113-
retcode = retcode or runcommand(UNITTEST_RUNNER + "examples")
120+
retcode = retcode or runpymodule(UNITTEST_RUNNER + "examples")
114121
elif opt == "--tck":
115-
retcode = runcommand('coverage report --show-missing') or\
116-
runcommands(["python", "-c", "from test.tck.configure_feature_files import *; set_up()"]) or\
117-
runcommand(BEHAVE_RUNNER) or\
118-
runcommands(["python", "-c", "from test.tck.configure_feature_files import *; clean_up()"])
122+
retcode = runpymodule('coverage report --show-missing') or \
123+
runcommands(["python", "-c", "\"from test.tck.configure_feature_files import *; set_up()\""]) or \
124+
runpymodule(BEHAVE_RUNNER) or \
125+
runcommands(["python", "-c", "\"from test.tck.configure_feature_files import *; clean_up()\""])
119126

120127
if retcode != 0:
121128
break

0 commit comments

Comments
 (0)