@@ -7,39 +7,38 @@ import { runValidateFileArgsTests } from './L0ValidateFileArgs';
7
7
describe ( 'Bash Suite' , function ( ) {
8
8
this . timeout ( parseInt ( process . env . TASK_TEST_TIMEOUT ) || 80000 ) ;
9
9
10
- function runValidations ( validator : ( ) => void , tr , done ) {
10
+ function runValidations ( validator : ( ) => void , tr : ttm . MockTestRunner ) {
11
11
try {
12
12
validator ( ) ;
13
- done ( ) ;
14
13
}
15
14
catch ( error ) {
16
15
console . log ( "STDERR" , tr . stderr ) ;
17
16
console . log ( "STDOUT" , tr . stdout ) ;
18
- done ( error ) ;
17
+ throw error ;
19
18
}
20
19
}
21
20
22
- it ( 'Runs an inline script correctly' , ( done : Mocha . Done ) => {
21
+ it ( 'Runs an inline script correctly' , async ( ) => {
23
22
delete process . env [ 'AZP_BASHV3_OLD_SOURCE_BEHAVIOR' ] ;
24
23
let tp : string = path . join ( __dirname , 'L0Inline.js' ) ;
25
24
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
26
25
27
- tr . run ( ) ;
26
+ await tr . runAsync ( ) ;
28
27
29
28
runValidations ( ( ) => {
30
29
assert ( tr . succeeded , 'Bash should have succeeded.' ) ;
31
30
assert ( tr . stderr . length === 0 , 'Bash should not have written to stderr' ) ;
32
31
assert ( tr . stdout . indexOf ( 'my script output' ) > 0 , 'Bash should have correctly run the script' ) ;
33
- } , tr , done ) ;
32
+ } , tr ) ;
34
33
} ) ;
35
34
36
- it ( 'Runs a checked in script correctly' , ( done : Mocha . Done ) => {
35
+ it ( 'Runs a checked in script correctly' , async ( ) => {
37
36
delete process . env [ 'AZP_BASHV3_OLD_SOURCE_BEHAVIOR' ] ;
38
37
process . env [ 'AZP_TASK_FF_BASHV3_ENABLE_SECURE_ARGS' ] = 'false'
39
38
let tp : string = path . join ( __dirname , 'L0External.js' ) ;
40
39
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
41
40
42
- tr . run ( ) ;
41
+ await tr . runAsync ( ) ;
43
42
44
43
runValidations ( ( ) => {
45
44
assert ( tr . succeeded , 'Bash should have succeeded.' ) ;
@@ -52,16 +51,16 @@ describe('Bash Suite', function () {
52
51
}
53
52
54
53
assert ( tr . stdout . indexOf ( 'my script output' ) > 0 , 'Bash should have correctly run the script' ) ;
55
- } , tr , done ) ;
54
+ } , tr ) ;
56
55
} ) ;
57
56
58
- it ( 'Runs a checked in script correctly when using the old behavior' , ( done : Mocha . Done ) => {
57
+ it ( 'Runs a checked in script correctly when using the old behavior' , async ( ) => {
59
58
process . env [ 'AZP_BASHV3_OLD_SOURCE_BEHAVIOR' ] = "true" ;
60
59
process . env [ 'AZP_TASK_FF_BASHV3_ENABLE_SECURE_ARGS' ] = 'false'
61
60
let tp : string = path . join ( __dirname , 'L0External.js' ) ;
62
61
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
63
62
64
- tr . run ( ) ;
63
+ await tr . runAsync ( ) ;
65
64
66
65
runValidations ( ( ) => {
67
66
assert ( tr . succeeded , 'Bash should have succeeded.' ) ;
@@ -74,16 +73,16 @@ describe('Bash Suite', function () {
74
73
}
75
74
76
75
assert ( tr . stdout . indexOf ( 'my script output' ) > 0 , 'Bash should have correctly run the script' ) ;
77
- } , tr , done ) ;
76
+ } , tr ) ;
78
77
} ) ;
79
78
80
- it ( 'Adds arguments to the script' , ( done : Mocha . Done ) => {
79
+ it ( 'Adds arguments to the script' , async ( ) => {
81
80
delete process . env [ 'AZP_BASHV3_OLD_SOURCE_BEHAVIOR' ] ;
82
81
process . env [ 'AZP_TASK_FF_BASHV3_ENABLE_SECURE_ARGS' ] = 'false'
83
82
let tp : string = path . join ( __dirname , 'L0Args.js' ) ;
84
83
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
85
84
86
- tr . run ( ) ;
85
+ await tr . runAsync ( ) ;
87
86
88
87
runValidations ( ( ) => {
89
88
assert ( tr . succeeded , 'Bash should have succeeded.' ) ;
@@ -96,59 +95,61 @@ describe('Bash Suite', function () {
96
95
}
97
96
98
97
assert ( tr . stdout . indexOf ( 'my script output' ) > 0 , 'Bash should have correctly run the script' ) ;
99
- } , tr , done ) ;
98
+ } , tr ) ;
100
99
} ) ;
101
100
102
- it ( 'Reports stderr correctly' , ( done : Mocha . Done ) => {
101
+ it ( 'Reports stderr correctly' , async ( ) => {
103
102
let tp : string = path . join ( __dirname , 'L0StdErr.js' ) ;
104
103
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
105
104
106
- tr . run ( ) ;
105
+ await tr . runAsync ( ) ;
107
106
108
107
runValidations ( ( ) => {
109
108
assert ( tr . failed , 'Bash should have failed' ) ;
110
109
assert ( tr . stdout . indexOf ( '##vso[task.issue type=error;source=CustomerScript;]myErrorTest' ) > 0 , 'Bash should have correctly written myErrorTest' ) ;
111
110
assert ( tr . stdout . length > 1000 , 'Bash stderr output is not truncated' ) ;
112
- } , tr , done ) ;
111
+ } , tr ) ;
113
112
} ) ;
114
113
115
- it ( 'Fails on exit code null' , ( done : Mocha . Done ) => {
114
+ it ( 'Fails on exit code null' , async ( ) => {
116
115
let tp : string = path . join ( __dirname , 'L0FailOnExitCodeNull.js' ) ;
117
116
let tr : ttm . MockTestRunner = new ttm . MockTestRunner ( tp ) ;
118
117
119
- tr . run ( ) ;
118
+ await tr . runAsync ( ) ;
120
119
121
120
runValidations ( ( ) => {
122
121
assert ( tr . failed , 'Bash should have failed when the script exits with null code' ) ;
123
- } , tr , done ) ;
122
+ } , tr ) ;
124
123
} ) ;
125
124
126
- it ( 'BASH_ENV - set environment variable' , ( done : Mocha . Done ) => {
125
+ it ( 'BASH_ENV - set environment variable' , async ( ) => {
127
126
delete process . env [ 'BASH_ENV' ] ;
127
+ process . env [ 'SYSTEM_DEBUG' ] = 'true' ;
128
128
129
129
const testPath : string = path . join ( __dirname , 'L0SetBashEnv.js' ) ;
130
130
const taskRunner : ttm . MockTestRunner = new ttm . MockTestRunner ( testPath ) ;
131
131
132
- taskRunner . run ( ) ;
132
+ await taskRunner . runAsync ( ) ;
133
133
134
134
runValidations ( ( ) => {
135
135
assert ( taskRunner . succeeded , 'Bash should have succeeded.' ) ;
136
136
assert ( taskRunner . stdout . indexOf ( 'The BASH_ENV environment variable was set to ~/.profile' ) > 0 , 'Task should set BASH_ENV to ~/.profile' ) ;
137
- } , taskRunner , done ) ;
137
+ } , taskRunner ) ;
138
138
} ) ;
139
139
140
- it ( 'BASH_ENV - override environment variable' , ( done : Mocha . Done ) => {
140
+ it ( 'BASH_ENV - override environment variable' , async ( ) => {
141
141
process . env [ 'BASH_ENV' ] = 'some/custom/path' ;
142
+ process . env [ 'SYSTEM_DEBUG' ] = 'true' ;
142
143
143
144
const testPath : string = path . join ( __dirname , 'L0SetBashEnv.js' ) ;
144
145
const taskRunner : ttm . MockTestRunner = new ttm . MockTestRunner ( testPath ) ;
145
146
146
- taskRunner . run ( ) ;
147
+ await taskRunner . runAsync ( ) ;
147
148
148
149
runValidations ( ( ) => {
149
150
assert ( taskRunner . succeeded , 'Bash should have succeeded.' ) ;
150
151
assert ( taskRunner . stdout . indexOf ( 'The BASH_ENV environment variable was set to ~/.profile' ) > 0 , 'Task should override the value of BASH_ENV with ~/.profile' ) ;
151
- } , taskRunner , done ) ;
152
+ } , taskRunner ) ;
152
153
} ) ;
153
154
154
155
describe ( 'File args env processing tests' , ( ) => {
0 commit comments