-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
46 lines (41 loc) · 898 Bytes
/
test.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
import os
import os.path
import subprocess
import sys
RUN_KARMA_TESTS = "karma start"
WEBPACK_FILE = "webpack.config.js"
WEBPACK_FILE_BACKUP = "webpack.config.js.backup"
WEBPACK_CONFIG = """module.exports = {
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.vue$/,
loader: 'vue-loader'
}
]
},
resolve: {
alias: {
vue: 'vue/dist/vue.js'
}
}
}"""
backup = os.path.isfile(WEBPACK_FILE)
if backup:
os.rename(WEBPACK_FILE, WEBPACK_FILE_BACKUP)
with open(WEBPACK_FILE, "w") as fo:
fo.write(WEBPACK_CONFIG)
output = ""
try:
output = subprocess.check_output(RUN_KARMA_TESTS, shell=True)
except subprocess.CalledProcessError as e:
output = e.output
print output
os.remove(WEBPACK_FILE)
if backup:
os.rename(WEBPACK_FILE_BACKUP, WEBPACK_FILE)