forked from robotframework/robotframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_jasmine.py
More file actions
executable file
·53 lines (45 loc) · 1.62 KB
/
run_jasmine.py
File metadata and controls
executable file
·53 lines (45 loc) · 1.62 KB
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
#!/usr/bin/env python
from __future__ import print_function
import urllib2
import shutil
import os
from os.path import join, exists, dirname, abspath
from glob import glob
from subprocess import call
from zipfile import ZipFile
JASMINE_REPORTER_URL='https://github.com/larrymyers/jasmine-reporters/zipball/0.2.1'
BASE = abspath(dirname(__file__))
REPORT_DIR = join(BASE, 'jasmine-results')
EXT_LIB = join(BASE, '..', 'ext-lib')
JARDIR = join(EXT_LIB, 'jasmine-reporters', 'ext')
def run_tests():
workdir = os.getcwd()
os.chdir(BASE)
download_jasmine_reporters()
clear_reports()
run()
os.chdir(workdir)
def run():
cmd = ['java', '-cp', '%s%s%s' % (join(JARDIR, 'js.jar'), os.pathsep, join(JARDIR, 'jline.jar')),
'org.mozilla.javascript.tools.shell.Main', '-opt', '-1', 'envjs.bootstrap.js',
join(BASE, 'webcontent', 'SpecRunner.html')]
call(cmd)
def clear_reports():
if exists(REPORT_DIR):
shutil.rmtree(REPORT_DIR)
os.mkdir(REPORT_DIR)
def download_jasmine_reporters():
if exists(join(EXT_LIB, 'jasmine-reporters')):
return
if not exists(EXT_LIB):
os.mkdir(EXT_LIB)
reporter = urllib2.urlopen(JASMINE_REPORTER_URL)
with open(join(EXT_LIB, 'tmp.zip'), 'w') as temp:
temp.write(reporter.read())
with open(join(EXT_LIB, 'tmp.zip'), 'r') as temp:
ZipFile(temp).extractall(EXT_LIB)
extraction_dir = glob(join(EXT_LIB, 'larrymyers-jasmine-reporters*'))[0]
print('Extracting Jasmine-Reporters to', extraction_dir)
shutil.move(extraction_dir, join(EXT_LIB, 'jasmine-reporters'))
if __name__ == '__main__':
run_tests()