'run-test.py' script should make sure 'node_modules' directory exists before installi...
[WebKit-https.git] / Websites / perf.webkit.org / tools / run-tests.py
1 #!/usr/bin/python
2
3 import os
4 import subprocess
5 import sys
6
7
8 def main():
9     tools_dir = os.path.dirname(__file__)
10     root_dir = os.path.abspath(os.path.join(tools_dir, '..'))
11     node_modules_dir = os.path.join(root_dir, 'node_modules')
12
13     os.makedirs(node_modules_dir)
14     packages = ['mocha', 'pg', 'form-data']
15     for package_name in packages:
16         target_dir = os.path.join(node_modules_dir, package_name)
17         if not os.path.isdir(target_dir):
18             subprocess.call(['npm', 'install', package_name], cwd=node_modules_dir)
19
20     mocha_path = os.path.join(node_modules_dir, 'mocha/bin/mocha')
21     test_paths = sys.argv[1:] or ['unit-tests', 'server-tests']
22     return subprocess.call([mocha_path] + test_paths)
23
24 if __name__ == "__main__":
25     main()