forked from Chevrotain/chevrotain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
174 lines (157 loc) · 5.5 KB
/
gruntfile.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
const _ = require("lodash")
const karmaConf = process.env.TRAVIS ? "karma_sauce.conf.js" : "karma.conf.js"
const fourSpaces = " "
const examples_test_command = "yarn test"
const INSTALL_LINK = "yarn install && yarn link chevrotain"
const INSTALL_LINK_TEST = INSTALL_LINK + " && " + examples_test_command
const UNLINK = " && yarn unlink chevrotain"
const banner = "/*! <%= pkg.name %> - v<%= pkg.version %> */"
module.exports = function(grunt) {
const pkg = grunt.file.readJSON("package.json")
//noinspection UnnecessaryLabelJS
grunt.initConfig({
pkg: pkg,
run: {
options: {
failOnError: true
},
yarn_link: {
exec: "yarn link"
},
test_examples_lexer: {
options: {
cwd: process.cwd() + "/examples/lexer/"
},
exec: INSTALL_LINK_TEST + UNLINK
},
test_examples_grammars: {
options: {
cwd: process.cwd() + "/examples/grammars/"
},
exec: INSTALL_LINK_TEST + UNLINK
},
test_examples_parser: {
options: {
cwd: process.cwd() + "/examples/parser/"
},
exec:
INSTALL_LINK +
" && " +
"grunt --gruntfile minification/gruntfile.js" +
" && " +
"cd webpack" +
" && " +
"yarn install" +
" && " +
"yarn link chevrotain" +
" && " +
"cd .." +
" && " +
examples_test_command +
UNLINK
},
test_examples_implementation_languages: {
options: {
cwd: process.cwd() + "/examples/implementation_languages/"
},
exec: INSTALL_LINK + " && yarn test" + UNLINK
},
test_examples_tutorial: {
options: {
cwd: process.cwd() + "/examples/tutorial/"
},
exec: INSTALL_LINK + " && yarn test" + UNLINK
},
test_examples_custom_apis: {
options: {
cwd: process.cwd() + "/examples/custom_apis/"
},
exec: INSTALL_LINK + " && yarn test" + UNLINK
}
},
karma: {
options: {
configFile: karmaConf,
singleRun: true,
client: {
captureConsole: true
}
},
browsers_unit_tests: {
options: {
port: 9980,
files: ["test/test.config.js", "lib/chevrotainSpecs.js"]
}
},
browsers_integration_tests_globals: {
options: {
port: 9982,
files: [
"lib/chevrotain.js",
"test/test.config.js",
"test_integration/**/*spec.js"
]
}
},
browsers_integration_tests_amd: {
options: {
port: 9983,
frameworks: ["requirejs", "mocha", "chai"],
files: [
"lib/chevrotain.js",
"test/test.config.js",
{
pattern: "test_integration/*/*.js",
included: false
},
"test_integration/integration_tests_main.js"
]
}
},
browsers_integration_tests_globals_minified: {
options: {
port: 9984,
files: [
"lib/chevrotain.min.js",
"test/test.config.js",
"test_integration/**/*spec.js"
]
}
},
browsers_integration_tests_amd_minified: {
options: {
port: 9985,
frameworks: ["requirejs", "mocha", "chai"],
files: [
"lib/chevrotain.min.js",
"test/test.config.js",
{
pattern: "test_integration/*/*.js",
included: false
},
"test_integration/integration_tests_main.js"
]
}
}
}
})
require("load-grunt-tasks")(grunt)
const integrationTestsNodeTasks = [
"run:yarn_link",
"run:test_examples_grammars",
"run:test_examples_parser",
"run:test_examples_lexer",
"run:test_examples_implementation_languages",
"run:test_examples_tutorial",
"run:test_examples_custom_apis"
]
const browserTestsTasks = [
"karma:browsers_unit_tests",
"karma:browsers_integration_tests_globals",
"karma:browsers_integration_tests_globals_minified",
"karma:browsers_integration_tests_amd",
"karma:browsers_integration_tests_amd_minified"
]
grunt.registerTask("browsers_tests", browserTestsTasks)
grunt.registerTask("integration_tests", integrationTestsNodeTasks)
}