1
- /*
2
- Copyright (c) 2012, 2015 Oracle and/or its affiliates. All rights
1
+ /*
2
+ Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights
3
3
reserved.
4
4
5
5
This program is free software; you can redistribute it and/or
@@ -37,6 +37,7 @@ function Suite(driver, name, suiteDir) {
37
37
this . path = "" ;
38
38
39
39
this . tests = [ ] ;
40
+ this . disabledTests = { } ;
40
41
this . smokeTest = { } ;
41
42
this . smokeTestHasFailed = null ;
42
43
this . serialTests = [ ] ;
@@ -63,16 +64,23 @@ Suite.prototype.addTest = function(filename, test) {
63
64
test . filename = path . resolve ( this . path , filename ) ;
64
65
test . suite = this ;
65
66
test . reset ( ) ;
66
- this . tests . push ( test ) ; // should check if test has been disabled
67
+ this . tests . push ( test ) ;
68
+ if ( this . disabledTests [ filename ] &&
69
+ this . disabledTests [ filename ] . test ( test . name ) )
70
+ test . enabled = false ;
71
+ } ;
72
+
73
+ Suite . prototype . disableTest = function ( fileName , testNamePattern ) {
74
+ this . disabledTests [ fileName ] = testNamePattern ;
67
75
} ;
68
76
69
- /* addTestsFromFile(f, onlyTests)
70
- f is a fully resolved pathname
71
- onlyTests is a string containing a comma separated list of
77
+ /* addTestsFromFile(fileName, onlyTests)
78
+ onlyTests is a string containing a comma separated list of
72
79
test numbers. If set, only those elements of the test array are added.
73
80
*/
74
- Suite . prototype . addTestsFromFile = function ( f , onlyTests ) {
75
- var t , i , j , k , testList , testHash ;
81
+ Suite . prototype . addTestsFromFile = function ( fileName , onlyTests ) {
82
+ var f , t , i , j , k , testList , testHash ;
83
+ f = path . join ( this . path , fileName ) ;
76
84
if ( onlyTests ) {
77
85
onlyTests = String ( onlyTests ) ;
78
86
testList = onlyTests . split ( "," ) ;
@@ -82,17 +90,17 @@ Suite.prototype.addTestsFromFile = function(f, onlyTests) {
82
90
testHash [ k ] = 1 ;
83
91
}
84
92
}
85
- if ( re_matching_test_case . test ( f ) ) {
93
+ if ( re_matching_test_case . test ( fileName ) ) {
86
94
t = require ( f ) ;
87
95
if ( typeof ( t . tests ) === 'object' && t . tests instanceof Array ) {
88
96
for ( j = 0 ; j < t . tests . length ; j ++ ) {
89
97
if ( onlyTests === null || testHash [ j ] === 1 ) {
90
- this . addTest ( f , t . tests [ j ] ) ;
98
+ this . addTest ( fileName , t . tests [ j ] ) ;
91
99
}
92
100
}
93
101
}
94
102
else if ( typeof ( t . isTest ) === 'function' && t . isTest ( ) ) {
95
- this . addTest ( f , t ) ;
103
+ this . addTest ( fileName , t ) ;
96
104
}
97
105
else {
98
106
console . log ( "Warning: " + f + " does not export a Test." ) ;
@@ -110,17 +118,17 @@ Suite.prototype.createTests = function() {
110
118
var testFile = this . path ;
111
119
this . path = path . dirname ( testFile ) ;
112
120
try {
113
- this . addTestsFromFile ( path . join ( this . path , "SmokeTest.js" ) , null ) ;
121
+ this . addTestsFromFile ( "SmokeTest.js" , null ) ;
114
122
} catch ( ignore ) { }
115
123
this . addTestsFromFile ( testFile , this . driver . testInFile ) ;
116
124
try {
117
- this . addTestsFromFile ( path . join ( this . path , "ClearSmokeTest.js" ) , null ) ;
125
+ this . addTestsFromFile ( "ClearSmokeTest.js" , null ) ;
118
126
} catch ( ignore ) { }
119
127
}
120
128
else if ( stat . isDirectory ( ) ) {
121
129
var files = fs . readdirSync ( this . path ) ;
122
130
for ( i = 0 ; i < files . length ; i ++ ) {
123
- this . addTestsFromFile ( path . join ( this . path , files [ i ] ) , null ) ;
131
+ this . addTestsFromFile ( files [ i ] , null ) ;
124
132
}
125
133
}
126
134
}
0 commit comments