Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Commit b85873e

Browse files
committed
add syntax test:
- use jshint and glob to look for 'fdescribe' and 'fit' in test/jasmine/tests/
1 parent 81b9f79 commit b85873e

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"test-jasmine": "karma start test/jasmine/karma.conf.js",
3333
"citest-jasmine": "karma start test/jasmine/karma.ciconf.js",
3434
"test-image": "./tasks/test_image.sh",
35+
"test-syntax": "node test/syntax_test.js",
3536
"test": "npm run test-jasmine && npm test-image",
3637
"start-test_dashboard": "node devtools/test_dashboard/server.js",
3738
"start-image_viewer": "node devtools/image_viewer/server.js",
@@ -63,6 +64,7 @@
6364
"gl-select-box": "^1.0.1",
6465
"gl-spikes2d": "^1.0.1",
6566
"gl-surface3d": "^1.0.6",
67+
"glob": "^6.0.1",
6668
"mouse-change": "^1.1.1",
6769
"mouse-wheel": "^1.0.2",
6870
"ndarray": "^1.0.16",

tasks/util/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module.exports = {
4242
pathToTestImagesDiff: path.join(pathToBuild, 'test_images_diff/'),
4343
pathToTestImagesDiffList: path.join(pathToBuild, 'list_of_incorrect_images.txt'),
4444

45+
pathToJasmineTests: path.join(pathToRoot, 'test/jasmine/tests'),
46+
4547
uglifyOptions: {
4648
fromString: true,
4749
mangle: true,

test/syntax_test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var path = require('path');
2+
var fs = require('fs');
3+
4+
var jshint = require('jshint').JSHINT;
5+
var glob = require('glob');
6+
7+
var constants = require('../tasks/util/constants');
8+
9+
var focusGlobals = ['fdescribe', 'fit'];
10+
var logs = [];
11+
12+
13+
glob(path.join(constants.pathToJasmineTests, '**/*.js'), function(err, files) {
14+
files.forEach(function(file) {
15+
var code = fs.readFileSync(file, 'utf-8');
16+
17+
jshint(code);
18+
19+
var impliedGlobals = jshint.data().implieds;
20+
21+
impliedGlobals.forEach(function(obj) {
22+
if(focusGlobals.indexOf(obj.name) !== -1) {
23+
logs.push([
24+
path.basename(file),
25+
'[line ' + obj.line + '] :',
26+
'contains either a *fdescribe* or a *fit* block.'
27+
].join(' '));
28+
}
29+
});
30+
});
31+
32+
if(logs.length) throw new Error(logs.join('\n'));
33+
});

0 commit comments

Comments
 (0)