Skip to content

Commit 5627584

Browse files
authored
Merge pull request #1419 from plotly/more-syntax-tests
More syntax tests
2 parents 5406829 + 9f1c6c4 commit 5627584

File tree

79 files changed

+155
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+155
-96
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"open": "0.0.5",
126126
"prepend-file": "^1.3.1",
127127
"prettysize": "0.0.3",
128+
"read-last-lines": "^1.1.0",
128129
"requirejs": "^2.3.1",
129130
"through2": "^2.0.3",
130131
"uglify-js": "^2.7.5",

src/traces/parcoords/shaders/pick_vertex.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void main() {
5151
mat4 pB = mat4(p4, p5, p6, p7);
5252
mat4 pC = mat4(p8, p9, pa, pb);
5353
mat4 pD = mat4(pc, pd, pe, abs(pf));
54-
54+
5555
float show = float(mshow(pA, loA, hiA) &&
5656
mshow(pB, loB, hiB) &&
5757
mshow(pC, loC, hiC) &&

src/traces/parcoords/shaders/vertex.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void main() {
5151
mat4 pB = mat4(p4, p5, p6, p7);
5252
mat4 pC = mat4(p8, p9, pa, pb);
5353
mat4 pD = mat4(pc, pd, pe, abs(pf));
54-
54+
5555
float show = float(mshow(pA, loA, hiA) &&
5656
mshow(pB, loB, hiB) &&
5757
mshow(pC, loC, hiC) &&

tasks/test_syntax.js

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var fs = require('fs');
44
var falafel = require('falafel');
55
var glob = require('glob');
66
var madge = require('madge');
7+
var readLastLines = require('read-last-lines');
78

89
var constants = require('./util/constants');
910
var srcGlob = path.join(constants.pathToSrc, '**/*.js');
@@ -17,6 +18,7 @@ var EXIT_CODE = 0;
1718
assertJasmineSuites();
1819
assertSrcContents();
1920
assertFileNames();
21+
assertTrailingNewLine();
2022
assertCircularDeps();
2123

2224

@@ -90,24 +92,80 @@ function assertSrcContents() {
9092

9193
// check that all file names are in lower case
9294
function assertFileNames() {
95+
var pattern = combineGlobs([
96+
path.join(constants.pathToRoot, '*.*'),
97+
path.join(constants.pathToSrc, '**/*.*'),
98+
path.join(constants.pathToLib, '**/*.*'),
99+
path.join(constants.pathToDist, '**/*.*'),
100+
path.join(constants.pathToRoot, 'test', '**/*.*'),
101+
path.join(constants.pathToRoot, 'tasks', '**/*.*'),
102+
path.join(constants.pathToRoot, 'devtools', '**/*.*')
103+
]);
104+
93105
var logs = [];
94106

95-
glob(combineGlobs([srcGlob, libGlob, testGlob, bundleTestGlob]), function(err, files) {
107+
glob(pattern, function(err, files) {
96108
files.forEach(function(file) {
97109
var base = path.basename(file);
98110

111+
if(
112+
base === 'README.md' ||
113+
base === 'CONTRIBUTING.md' ||
114+
base === 'CHANGELOG.md' ||
115+
base === 'SECURITY.md' ||
116+
file.indexOf('mathjax') !== -1
117+
) return;
118+
99119
if(base !== base.toLowerCase()) {
100120
logs.push([
101-
file, ' :',
121+
file, ':',
102122
'has a file name containing some',
103123
'non-lower-case characters'
104-
]);
124+
].join(' '));
105125
}
106126
});
107127

108128
log('lower case only file names', logs);
109129
});
130+
}
131+
132+
// check that all files have a trailing new line character
133+
function assertTrailingNewLine() {
134+
var pattern = combineGlobs([
135+
path.join(constants.pathToSrc, '**/*.glsl'),
136+
path.join(constants.pathToRoot, 'test', 'image', 'mocks', '*')
137+
]);
138+
139+
var regexNewLine = /\r?\n$/;
140+
var regexEmptyNewLine = /^\r?\n$/;
141+
var promises = [];
142+
var logs = [];
143+
144+
glob(pattern, function(err, files) {
145+
files.forEach(function(file) {
146+
var promise = readLastLines.read(file, 1);
110147

148+
promises.push(promise);
149+
150+
promise.then(function(lines) {
151+
if(!regexNewLine.test(lines)) {
152+
logs.push([
153+
file, ':',
154+
'does not have a trailing new line character'
155+
].join(' '));
156+
} else if(regexEmptyNewLine.test(lines)) {
157+
logs.push([
158+
file, ':',
159+
'has more than one trailing new line'
160+
].join(' '));
161+
}
162+
});
163+
});
164+
165+
Promise.all(promises).then(function() {
166+
log('trailing new line character', logs);
167+
});
168+
});
111169
}
112170

113171
// check circular dependencies
@@ -137,6 +195,7 @@ function combineGlobs(arr) {
137195
function log(name, logs) {
138196
if(logs.length) {
139197
console.error('test-syntax error [' + name + ']');
198+
console.error(logs.join('\n'));
140199
EXIT_CODE = 1;
141200
} else {
142201
console.log('ok ' + name);

0 commit comments

Comments
 (0)