|
3 | 3 | import shutil
|
4 | 4 | import subprocess
|
5 | 5 | import platform
|
6 |
| -from subprocess import Popen, PIPE |
7 | 6 | import sys
|
8 | 7 |
|
| 8 | +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 9 | +from nw_util import * |
| 10 | + |
9 | 11 | from selenium import webdriver
|
10 | 12 | from selenium.webdriver.chrome.options import Options
|
11 | 13 | chrome_options = Options()
|
12 | 14 | testdir = os.path.dirname(os.path.abspath(__file__))
|
13 | 15 | chrome_options.add_argument("nwapp=" + testdir)
|
14 |
| -nw_tools = os.path.normpath(os.path.join(testdir, os.pardir, os.pardir, os.pardir, 'tools')) |
15 |
| -sys.path.append(nw_tools) |
16 |
| -import getnwversion |
17 |
| -import getnwisrelease |
18 |
| - |
19 |
| -def find_executable(executable, path=None): |
20 |
| - """Find if 'executable' can be run. Looks for it in 'path' |
21 |
| - (string that lists directories separated by 'os.pathsep'; |
22 |
| - defaults to os.environ['PATH']). Checks for all executable |
23 |
| - extensions. Returns full path or None if no command is found. |
24 |
| - """ |
25 |
| - if path is None: |
26 |
| - path = os.environ['PATH'] |
27 |
| - paths = path.split(os.pathsep) |
28 |
| - extlist = [''] |
29 |
| - if os.name == 'os2': |
30 |
| - (base, ext) = os.path.splitext(executable) |
31 |
| - # executable files on OS/2 can have an arbitrary extension, but |
32 |
| - # .exe is automatically appended if no dot is present in the name |
33 |
| - if not ext: |
34 |
| - executable = executable + ".exe" |
35 |
| - elif sys.platform == 'win32': |
36 |
| - pathext = os.environ['PATHEXT'].lower().split(os.pathsep) |
37 |
| - (base, ext) = os.path.splitext(executable) |
38 |
| - if ext.lower() not in pathext: |
39 |
| - extlist = pathext |
40 |
| - for ext in extlist: |
41 |
| - execname = executable + ext |
42 |
| - if os.path.isfile(execname): |
43 |
| - return execname |
44 |
| - else: |
45 |
| - for p in paths: |
46 |
| - f = os.path.join(p, execname) |
47 |
| - if os.path.isfile(f): |
48 |
| - return f |
49 |
| - else: |
50 |
| - return None |
51 | 16 |
|
52 | 17 | os.chdir(testdir)
|
53 | 18 |
|
54 |
| -header_path = os.path.abspath("../../../tmp/node") |
55 |
| - |
56 |
| -nw_version = getnwversion.nw_version |
57 |
| -if getnwisrelease.release == 0: |
58 |
| - nw_version += getnwisrelease.postfix |
59 |
| - |
60 |
| -arch = '' |
61 |
| -_arch = platform.architecture()[0] |
62 |
| -if _arch == '64bit': |
63 |
| - arch = 'x64' |
64 |
| -elif _arch == '32bit': |
65 |
| - arch = 'ia32' |
66 |
| -else: |
67 |
| - print 'Unsupported arch: ' + _arch |
68 |
| - exit(-1) |
69 |
| - |
70 |
| -nw_gyp_path = find_executable('nw-gyp') |
71 |
| -npm_path = find_executable('npm') |
72 |
| -npm_cmdline = [npm_path, 'install'] |
73 |
| - |
74 |
| -if sys.platform in ('win32', 'cygwin'): |
75 |
| - nw_gyp_path = os.path.join(os.path.dirname(nw_gyp_path), |
76 |
| - 'node_modules', 'nw-gyp', 'bin', 'nw-gyp.js') |
77 |
| - npm_cmdline = [npm_path, 'install', '--msvs_version=2015'] |
78 |
| - |
79 |
| -print "nw_gyp: ", nw_gyp_path |
80 |
| -print "npm_path: ", npm_path |
81 |
| -print "header path: ", header_path |
82 |
| -print "command line: ", npm_cmdline |
83 |
| - |
84 |
| -npm_env = {'npm_config_nodedir': header_path, 'npm_config_target': nw_version, |
85 |
| - 'npm_config_arch': arch, 'npm_config_target_arch': arch, |
86 |
| - 'npm_config_runtime': 'node-webkit', 'npm_config_build_from_source': "true", |
87 |
| - 'npm_config_node_gyp': nw_gyp_path, 'PATH': os.getenv('PATH')} |
88 |
| - |
89 |
| -os.environ.update(npm_env) |
90 |
| - |
91 |
| -proc = Popen(npm_cmdline, stdout=PIPE, stderr=PIPE, env=os.environ) |
92 |
| -out, err = proc.communicate() |
93 |
| -print out |
94 |
| -print err |
95 |
| -assert(proc.returncode == 0) |
| 19 | +install_native_modules() |
96 | 20 |
|
97 | 21 | driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
|
98 | 22 | try:
|
|
0 commit comments