-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_demo.py
56 lines (37 loc) · 1.22 KB
/
run_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#
#
# Run demo - cypress test of tictactoe react app
# argv[1] - cypress o(pen) / r(un)
# argv[2] - percy -> run with percy
# argv[3] - PERCY_BRANCH=master|local
# argv[4] - PERCH_TOKEN=<from percy.io>
#
#
import subprocess
import sys
import os
if len(sys.argv) != 2 and len(sys.argv) != 5:
print("Unsupported number of arguments: ", len(sys.argv))
sys.exit(-1)
myEnv = os.environ
myEnv["PERCY_BRANCH"] = sys.argv[3]
myEnv["PERCY_TOKEN"] = sys.argv[4]
subprocess.check_output("git checkout demo_v1", shell=True)
# spawn a new cmd prompt window with "npm start"
p = subprocess.Popen([r'start', r'cmd', '/k', r'npm', r'start'], shell=True)
subprocess.check_output("git checkout demo_cypress_v1", shell=True)
cypressCmd = r'cypress'
if sys.argv[1] == 'o':
cypressArg1 = r'open'
elif sys.argv[1] == 'r':
cypressArg1 = r'run'
else:
print("Invalid cypress option: ", sys.argv[1])
sys.exit(-1)
if len(sys.argv) == 5 and sys.argv[2] == 'percy':
cmd = r'node_modules\\.bin\\percy'
arg1 = r'exec'
arg2 = r'--'
arg3 = cypressCmd
arg4 = cypressArg1
subprocess.Popen([cmd, arg1, arg2, cypressCmd, cypressArg1], env=myEnv, shell=True)