@@ -3,6 +3,7 @@ var fs = require('fs');
3
3
4
4
var falafel = require ( 'falafel' ) ;
5
5
var glob = require ( 'glob' ) ;
6
+ var madge = require ( 'madge' ) ;
6
7
7
8
var constants = require ( './util/constants' ) ;
8
9
var srcGlob = path . join ( constants . pathToSrc , '**/*.js' ) ;
@@ -14,6 +15,7 @@ var bundleTestGlob = path.join(constants.pathToJasmineBundleTests, '**/*.js');
14
15
assertJasmineSuites ( ) ;
15
16
assertHeaders ( ) ;
16
17
assertFileNames ( ) ;
18
+ assertCircularDeps ( ) ;
17
19
18
20
19
21
// check for for focus and exclude jasmine blocks
@@ -38,7 +40,7 @@ function assertJasmineSuites() {
38
40
39
41
} ) ;
40
42
41
- log ( logs ) ;
43
+ log ( 'no jasmine suites focus/exclude blocks' , logs ) ;
42
44
} ) ;
43
45
}
44
46
@@ -68,7 +70,7 @@ function assertHeaders() {
68
70
}
69
71
} ) ;
70
72
71
- log ( logs ) ;
73
+ log ( 'correct headers in lib/ and src/' , logs ) ;
72
74
} ) ;
73
75
}
74
76
@@ -89,17 +91,38 @@ function assertFileNames() {
89
91
}
90
92
} ) ;
91
93
92
- log ( logs ) ;
94
+ log ( 'lower case only file names' , logs ) ;
93
95
} ) ;
94
96
95
97
}
96
98
99
+ // check circular dependencies
100
+ function assertCircularDeps ( ) {
101
+ var dependencyObject = madge ( constants . pathToSrc ) ;
102
+ var circularDeps = dependencyObject . circular ( ) . getArray ( ) ;
103
+ var logs = [ ] ;
104
+
105
+ // as of v1.17.0 - 2016/09/08
106
+ // see https://github.com/plotly/plotly.js/milestone/9
107
+ // for more details
108
+ var MAX_ALLOWED_CIRCULAR_DEPS = 33 ;
109
+
110
+ if ( circularDeps . length > MAX_ALLOWED_CIRCULAR_DEPS ) {
111
+ logs . push ( 'some new circular dependencies were added to src/' ) ;
112
+ }
113
+
114
+ log ( 'circular dependencies' , logs ) ;
115
+ }
116
+
97
117
function combineGlobs ( arr ) {
98
118
return '{' + arr . join ( ',' ) + '}' ;
99
119
}
100
120
101
- function log ( logs ) {
121
+ function log ( name , logs ) {
102
122
if ( logs . length ) {
123
+ console . error ( 'test-syntax error [' + name + ']\n' ) ;
103
124
throw new Error ( '\n' + logs . join ( '\n' ) + '\n' ) ;
104
125
}
126
+
127
+ console . log ( 'ok ' + name ) ;
105
128
}
0 commit comments