@@ -8,6 +8,11 @@ var readLastLines = require('read-last-lines');
8
8
var eslint = require ( 'eslint' ) ;
9
9
var trueCasePath = require ( 'true-case-path' ) ;
10
10
11
+ var common = require ( './util/common' ) ;
12
+ var isJasmineTestIt = common . isJasmineTestIt ;
13
+ var isJasmineTestDescribe = common . isJasmineTestDescribe ;
14
+ var hasJasmineTestTag = common . hasJasmineTestTag ;
15
+
11
16
var constants = require ( './util/constants' ) ;
12
17
var srcGlob = path . join ( constants . pathToSrc , '**/*.js' ) ;
13
18
var libGlob = path . join ( constants . pathToLib , '**/*.js' ) ;
@@ -28,26 +33,55 @@ assertES5();
28
33
// check for for focus and exclude jasmine blocks
29
34
function assertJasmineSuites ( ) {
30
35
var BLACK_LIST = [ 'fdescribe' , 'fit' , 'xdescribe' , 'xit' ] ;
36
+ var TAGS = [ 'noCI' , 'noCIdep' , 'gl' , 'flaky' ] ;
31
37
var logs = [ ] ;
32
38
33
39
glob ( combineGlobs ( [ testGlob , bundleTestGlob ] ) , function ( err , files ) {
34
40
files . forEach ( function ( file ) {
35
41
var code = fs . readFileSync ( file , 'utf-8' ) ;
42
+ var bn = path . basename ( file ) ;
36
43
37
44
falafel ( code , { locations : true } , function ( node ) {
45
+ var lineInfo = '[line ' + node . loc . start . line + '] :' ;
46
+
38
47
if ( node . type === 'Identifier' && BLACK_LIST . indexOf ( node . name ) !== - 1 ) {
39
48
logs . push ( [
40
- path . basename ( file ) ,
41
- '[line ' + node . loc . start . line + '] :' ,
49
+ bn , lineInfo ,
42
50
'contains either a *fdescribe*, *fit*,' ,
43
51
'*xdescribe* or *xit* block.'
44
52
] . join ( ' ' ) ) ;
45
53
}
46
- } ) ;
47
54
55
+ if ( isJasmineTestIt ( node ) ) {
56
+ if ( hasJasmineTestTag ( node ) ) {
57
+ if ( TAGS . every ( function ( t ) { return ! hasJasmineTestTag ( node , t ) ; } ) ) {
58
+ logs . push ( [
59
+ bn , lineInfo ,
60
+ 'contains an unrecognized tag,' ,
61
+ 'not one of: ' + TAGS . map ( function ( t ) { return '\@' + t ; } ) . join ( ', ' )
62
+ ] . join ( ' ' ) ) ;
63
+ }
64
+ }
65
+
66
+ if ( hasJasmineTestTag ( node , 'gl' ) && hasJasmineTestTag ( node , 'flaky' ) ) {
67
+ logs . push ( [
68
+ bn , lineInfo ,
69
+ 'contains a @gl tag AND a @flaky tag, which is not allowed'
70
+ ] . join ( ' ' ) ) ;
71
+ }
72
+ }
73
+
74
+ if ( isJasmineTestDescribe ( node , 'gl' ) ) {
75
+ logs . push ( [
76
+ bn , lineInfo ,
77
+ 'contains a @gl tag is a *describe* block,' ,
78
+ '@gl tags are allowed only in jasmine *it* blocks.'
79
+ ] . join ( ' ' ) ) ;
80
+ }
81
+ } ) ;
48
82
} ) ;
49
83
50
- log ( 'no jasmine suites focus/exclude blocks' , logs ) ;
84
+ log ( 'no jasmine suites focus/exclude blocks or wrong tag patterns ' , logs ) ;
51
85
} ) ;
52
86
}
53
87
0 commit comments