@@ -35,19 +35,17 @@ describe('e2e', function () {
3535 describe ( '--version' , function ( ) {
3636 it ( 'shows version' , async function ( ) {
3737 const shell = this . startTestShell ( { args : [ '--version' ] } ) ;
38- await shell . waitForExit ( ) ;
38+ await shell . waitForSuccessfulExit ( ) ;
3939
40- shell . assertNoErrors ( ) ;
4140 shell . assertContainsOutput ( require ( '../package.json' ) . version ) ;
4241 } ) ;
4342 } ) ;
4443
4544 describe ( '--build-info' , function ( ) {
4645 it ( 'shows build info in JSON format' , async function ( ) {
4746 const shell = this . startTestShell ( { args : [ '--build-info' ] } ) ;
48- await shell . waitForExit ( ) ;
47+ await shell . waitForSuccessfulExit ( ) ;
4948
50- shell . assertNoErrors ( ) ;
5149 const data = JSON . parse ( shell . output ) ;
5250 expect ( Object . keys ( data ) ) . to . deep . equal ( [
5351 'version' ,
@@ -101,7 +99,7 @@ describe('e2e', function () {
10199 'process.report.getReport()' ,
102100 ] ,
103101 } ) ;
104- await shell . waitForExit ( ) ;
102+ await shell . waitForSuccessfulExit ( ) ;
105103 processReport = JSON . parse ( shell . output ) ;
106104 }
107105 expect ( data . runtimeGlibcVersion ) . to . equal (
@@ -118,8 +116,7 @@ describe('e2e', function () {
118116 '--nodb' ,
119117 ] ,
120118 } ) ;
121- await shell . waitForExit ( ) ;
122- shell . assertNoErrors ( ) ;
119+ await shell . waitForSuccessfulExit ( ) ;
123120 const deps = JSON . parse ( shell . output ) ;
124121 expect ( deps . nodeDriverVersion ) . to . be . a ( 'string' ) ;
125122 expect ( deps . libmongocryptVersion ) . to . be . a ( 'string' ) ;
@@ -176,34 +173,28 @@ describe('e2e', function () {
176173 } ) ;
177174 } ) ;
178175 it ( 'closes the shell when "exit" is entered' , async function ( ) {
179- const onExit = shell . waitForExit ( ) ;
180176 shell . writeInputLine ( 'exit' ) ;
181- expect ( await onExit ) . to . equal ( 0 ) ;
177+ await shell . waitForSuccessfulExit ( ) ;
182178 } ) ;
183179 it ( 'closes the shell when "quit" is entered' , async function ( ) {
184- const onExit = shell . waitForExit ( ) ;
185180 shell . writeInputLine ( 'quit' ) ;
186- expect ( await onExit ) . to . equal ( 0 ) ;
181+ await shell . waitForSuccessfulExit ( ) ;
187182 } ) ;
188183 it ( 'closes the shell with the specified exit code when "exit(n)" is entered' , async function ( ) {
189- const onExit = shell . waitForExit ( ) ;
190184 shell . writeInputLine ( 'exit(42)' ) ;
191- expect ( await onExit ) . to . equal ( 42 ) ;
185+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 42 ) ;
192186 } ) ;
193187 it ( 'closes the shell with the specified exit code when "quit(n)" is entered' , async function ( ) {
194- const onExit = shell . waitForExit ( ) ;
195188 shell . writeInputLine ( 'quit(42)' ) ;
196- expect ( await onExit ) . to . equal ( 42 ) ;
189+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 42 ) ;
197190 } ) ;
198191 it ( 'closes the shell with the pre-specified exit code when "exit" is entered' , async function ( ) {
199- const onExit = shell . waitForExit ( ) ;
200192 shell . writeInputLine ( 'process.exitCode = 42; exit()' ) ;
201- expect ( await onExit ) . to . equal ( 42 ) ;
193+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 42 ) ;
202194 } ) ;
203195 it ( 'closes the shell with the pre-specified exit code when "quit" is entered' , async function ( ) {
204- const onExit = shell . waitForExit ( ) ;
205196 shell . writeInputLine ( 'process.exitCode = 42; quit()' ) ;
206- expect ( await onExit ) . to . equal ( 42 ) ;
197+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 42 ) ;
207198 } ) ;
208199 it ( 'decorates internal errors with bug reporting information' , async function ( ) {
209200 const err = await shell . executeLine (
@@ -300,10 +291,8 @@ describe('e2e', function () {
300291 'sleep(100);print([1,2,3,4,5,6,7,8,9,10].reduce(\n(a,b) => { return a*b; }, 1))\n\n\n\n' ,
301292 { end : true }
302293 ) ;
303- const exitCode = await shell . waitForExit ( ) ;
304- expect ( exitCode ) . to . equal ( 0 ) ;
294+ await shell . waitForSuccessfulExit ( ) ;
305295 shell . assertContainsOutput ( '3628800' ) ;
306- shell . assertNoErrors ( ) ;
307296 } ) ;
308297 } ) ;
309298
@@ -1095,9 +1084,8 @@ describe('e2e', function () {
10951084 '[db.hello()].reduce(\n() => { return 11111*11111; },0)\n\n\n' ,
10961085 { end : true }
10971086 ) ;
1098- await shell . waitForExit ( ) ;
1087+ await shell . waitForSuccessfulExit ( ) ;
10991088 shell . assertContainsOutput ( '123454321' ) ;
1100- shell . assertNoErrors ( ) ;
11011089 } ) ;
11021090 } ) ;
11031091
@@ -1162,8 +1150,7 @@ describe('e2e', function () {
11621150 // when run under coverage, as we currently specify the location of
11631151 // coverage files via a relative path and nyc fails to write to that
11641152 // when started from a changed cwd.
1165- await shell . waitForExit ( ) ;
1166- shell . assertNoErrors ( ) ;
1153+ await shell . waitForSuccessfulExit ( ) ;
11671154 } ) ;
11681155
11691156 if ( ! jsContextFlags . includes ( '--jsContext=plain-vm' ) ) {
@@ -1202,7 +1189,7 @@ describe('e2e', function () {
12021189 await eventually ( ( ) => {
12031190 shell . assertContainsOutput ( 'Error: uh oh' ) ;
12041191 } ) ;
1205- expect ( await shell . waitForExit ( ) ) . to . equal ( 1 ) ;
1192+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 1 ) ;
12061193 } ) ;
12071194 }
12081195 } ) ;
@@ -1216,8 +1203,7 @@ describe('e2e', function () {
12161203 await eventually ( ( ) => {
12171204 shell . assertContainsOutput ( 'hello one' ) ;
12181205 } ) ;
1219- expect ( await shell . waitForExit ( ) ) . to . equal ( 0 ) ;
1220- shell . assertNoErrors ( ) ;
1206+ await shell . waitForSuccessfulExit ( ) ;
12211207 } ) ;
12221208
12231209 if ( ! jsContextFlags . includes ( '--jsContext=plain-vm' ) ) {
@@ -1244,7 +1230,7 @@ describe('e2e', function () {
12441230 await eventually ( ( ) => {
12451231 shell . assertContainsOutput ( 'Error: uh oh' ) ;
12461232 } ) ;
1247- expect ( await shell . waitForExit ( ) ) . to . equal ( 1 ) ;
1233+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 1 ) ;
12481234 } ) ;
12491235
12501236 it ( 'fails with the error if the loaded script throws asynchronously (setImmediate)' , async function ( ) {
@@ -1259,7 +1245,7 @@ describe('e2e', function () {
12591245 await eventually ( ( ) => {
12601246 shell . assertContainsOutput ( 'Error: uh oh' ) ;
12611247 } ) ;
1262- expect ( await shell . waitForExit ( ) ) . to . equal (
1248+ expect ( await shell . waitForAnyExit ( ) ) . to . equal (
12631249 jsContextFlags . includes ( '--jsContext=repl' ) ? 0 : 1
12641250 ) ;
12651251 } ) ;
@@ -1276,7 +1262,7 @@ describe('e2e', function () {
12761262 await eventually ( ( ) => {
12771263 shell . assertContainsOutput ( 'Error: uh oh' ) ;
12781264 } ) ;
1279- expect ( await shell . waitForExit ( ) ) . to . equal (
1265+ expect ( await shell . waitForAnyExit ( ) ) . to . equal (
12801266 jsContextFlags . includes ( '--jsContext=repl' ) ? 0 : 1
12811267 ) ;
12821268 } ) ;
@@ -1299,7 +1285,7 @@ describe('e2e', function () {
12991285 script ,
13001286 ] ,
13011287 } ) ;
1302- expect ( await shell . waitForExit ( ) ) . to . equal ( 0 ) ;
1288+ await shell . waitForSuccessfulExit ( ) ;
13031289
13041290 // Check that:
13051291 // - the script runs in the expected environment
@@ -1512,7 +1498,7 @@ describe('e2e', function () {
15121498 }
15131499 await shell . executeLine ( 'a = 42' ) ;
15141500 shell . writeInput ( '.exit\n' ) ;
1515- await shell . waitForExit ( ) ;
1501+ await shell . waitForSuccessfulExit ( ) ;
15161502
15171503 shell = await startTestShell ( ) ;
15181504 // Arrow up twice to skip the .exit line
@@ -1521,7 +1507,7 @@ describe('e2e', function () {
15211507 expect ( shell . output ) . to . include ( 'a = 42' ) ;
15221508 } ) ;
15231509 shell . writeInput ( '\n.exit\n' ) ;
1524- await shell . waitForExit ( ) ;
1510+ await shell . waitForSuccessfulExit ( ) ;
15251511
15261512 expect ( await fs . readFile ( historyPath , 'utf8' ) ) . to . match ( / ^ a = 4 2 $ / m) ;
15271513 } ) ;
@@ -1533,7 +1519,7 @@ describe('e2e', function () {
15331519
15341520 await shell . executeLine ( 'a = 42' ) ;
15351521 shell . writeInput ( '.exit\n' ) ;
1536- await shell . waitForExit ( ) ;
1522+ await shell . waitForSuccessfulExit ( ) ;
15371523
15381524 expect ( ( await fs . stat ( historyPath ) ) . mode & 0o077 ) . to . equal ( 0 ) ;
15391525 } ) ;
@@ -1544,7 +1530,7 @@ describe('e2e', function () {
15441530 await shell . executeLine ( 'a = 42' ) ;
15451531 await shell . executeLine ( 'foo = "bar"' ) ;
15461532 shell . writeInput ( '.exit\n' ) ;
1547- await shell . waitForExit ( ) ;
1533+ await shell . waitForAnyExit ( ) ; // db.auth() call fails because of --nodb
15481534
15491535 const contents = await fs . readFile ( historyPath , 'utf8' ) ;
15501536 expect ( contents ) . to . not . match ( / m y p a s s w o r d / ) ;
@@ -1603,7 +1589,7 @@ describe('e2e', function () {
16031589 `config.set("updateURL", ${ JSON . stringify ( httpServerUrl ) } )`
16041590 ) ;
16051591 shell . writeInputLine ( 'exit' ) ;
1606- await shell . waitForExit ( ) ;
1592+ await shell . waitForSuccessfulExit ( ) ;
16071593 }
16081594
16091595 delete env . CI ;
@@ -1623,13 +1609,13 @@ describe('e2e', function () {
16231609 ) . to . be . a ( 'string' ) ;
16241610 } ) ;
16251611 shell . writeInputLine ( 'exit' ) ;
1626- await shell . waitForExit ( ) ;
1612+ await shell . waitForSuccessfulExit ( ) ;
16271613 }
16281614
16291615 {
16301616 const shell = await startTestShell ( ) ;
16311617 shell . writeInputLine ( 'exit' ) ;
1632- await shell . waitForExit ( ) ;
1618+ await shell . waitForSuccessfulExit ( ) ;
16331619 shell . assertContainsOutput (
16341620 'mongosh 2023.4.15 is available for download: https://www.mongodb.com/try/download/shell'
16351621 ) ;
@@ -1799,7 +1785,7 @@ describe('e2e', function () {
17991785 '.mongodb.net/' ,
18001786 ] ,
18011787 } ) ;
1802- const exitCode = await shell . waitForExit ( ) ;
1788+ const exitCode = await shell . waitForAnyExit ( ) ;
18031789 expect ( exitCode ) . to . equal ( 1 ) ;
18041790 } ) ;
18051791
@@ -1813,7 +1799,7 @@ describe('e2e', function () {
18131799 '.mongodb.net/' ,
18141800 ] ,
18151801 } ) ;
1816- const exitCode = await shell . waitForExit ( ) ;
1802+ const exitCode = await shell . waitForAnyExit ( ) ;
18171803 expect ( exitCode ) . to . equal ( 1 ) ;
18181804 } ) ;
18191805
@@ -1904,7 +1890,7 @@ describe('e2e', function () {
19041890 ) ;
19051891
19061892 shell . writeInputLine ( 'exit' ) ;
1907- await shell . waitForExit ( ) ;
1893+ await shell . waitForSuccessfulExit ( ) ;
19081894 shell . assertNoErrors ( ) ;
19091895 } ) ;
19101896 } ) ;
@@ -1937,7 +1923,7 @@ describe('e2e', function () {
19371923 args : [ filename ] ,
19381924 env : { ...process . env , MONGOSH_RUN_NODE_SCRIPT : '1' } ,
19391925 } ) ;
1940- expect ( await shell . waitForExit ( ) ) . to . equal ( 0 ) ;
1926+ await shell . waitForSuccessfulExit ( ) ;
19411927 shell . assertContainsOutput ( '610' ) ;
19421928 } ) ;
19431929 } ) ;
0 commit comments