Skip to content

Commit 03e8b66

Browse files
pepkin88rhendric
authored andcommitted
feature detection in the test environment
Previously it was easy to miss testing generators, because of omitting the `--harmony` flag; even `make full` skipped testing generators. This commit introduces detecting support for certain syntax oriented language features, before running tests. We can also assume using Node.js v4 or higher, so generator support is implied.
1 parent 8ac8bb4 commit 03e8b66

4 files changed

Lines changed: 11 additions & 13 deletions

File tree

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ browser/livescript-min.js: browser/livescript.js
2828
package.json: package.json.ls
2929
$(LSC) --compile package.json.ls
3030

31-
.PHONY: build build-browser force full install dev-install test test-harmony coverage loc clean
31+
.PHONY: build build-browser force full install dev-install test coverage loc clean
3232

3333
all: build
3434

@@ -51,9 +51,6 @@ dev-install: package.json
5151
test: build
5252
./scripts/test
5353

54-
test-harmony: build
55-
node --harmony ./scripts/test
56-
5754
coverage: build
5855
$(ISTANBUL) cover ./scripts/test
5956

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"scripts": {
3636
"pretest": "make force && make force",
3737
"test": "make test",
38-
"test-harmony": "make test-harmony",
3938
"posttest": "git checkout -- lib"
4039
},
4140
"preferGlobal": true,

package.json.ls

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ bin:
3535
scripts:
3636
pretest: 'make force && make force'
3737
test: 'make test'
38-
'test-harmony': 'make test-harmony'
3938
posttest: 'git checkout -- lib'
4039

4140
prefer-global: true

scripts/test

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
return color + text + reset;
2222
}
2323

24+
function testSyntax(code) {
25+
try {
26+
eval(code);
27+
} catch (e) {
28+
return false;
29+
}
30+
return true;
31+
}
32+
2433
var startTime = Date.now();
2534
var passedTests = 0;
2635
var failedTests = 0;
@@ -156,13 +165,7 @@
156165

157166
var files = fs.readdirSync("test");
158167

159-
if (process.execArgv.indexOf("--harmony") < 0 && process.execArgv.indexOf("--harmony-generators") < 0) {
160-
files.splice(files.indexOf("generators.ls"), 1);
161-
} else {
162-
console.log("Testing with harmony.");
163-
}
164-
var supportsAsync = parseInt(process.versions.node.split('.')[0]) >= 7;
165-
if (supportsAsync) {
168+
if (testSyntax("(async function () {})")) {
166169
console.log("Testing with async.");
167170
} else {
168171
files.splice(files.indexOf("async.ls"), 1);

0 commit comments

Comments
 (0)