@@ -35,19 +35,17 @@ describe('e2e', function () {
35
35
describe ( '--version' , function ( ) {
36
36
it ( 'shows version' , async function ( ) {
37
37
const shell = this . startTestShell ( { args : [ '--version' ] } ) ;
38
- await shell . waitForExit ( ) ;
38
+ await shell . waitForSuccessfulExit ( ) ;
39
39
40
- shell . assertNoErrors ( ) ;
41
40
shell . assertContainsOutput ( require ( '../package.json' ) . version ) ;
42
41
} ) ;
43
42
} ) ;
44
43
45
44
describe ( '--build-info' , function ( ) {
46
45
it ( 'shows build info in JSON format' , async function ( ) {
47
46
const shell = this . startTestShell ( { args : [ '--build-info' ] } ) ;
48
- await shell . waitForExit ( ) ;
47
+ await shell . waitForSuccessfulExit ( ) ;
49
48
50
- shell . assertNoErrors ( ) ;
51
49
const data = JSON . parse ( shell . output ) ;
52
50
expect ( Object . keys ( data ) ) . to . deep . equal ( [
53
51
'version' ,
@@ -101,7 +99,7 @@ describe('e2e', function () {
101
99
'process.report.getReport()' ,
102
100
] ,
103
101
} ) ;
104
- await shell . waitForExit ( ) ;
102
+ await shell . waitForSuccessfulExit ( ) ;
105
103
processReport = JSON . parse ( shell . output ) ;
106
104
}
107
105
expect ( data . runtimeGlibcVersion ) . to . equal (
@@ -118,8 +116,7 @@ describe('e2e', function () {
118
116
'--nodb' ,
119
117
] ,
120
118
} ) ;
121
- await shell . waitForExit ( ) ;
122
- shell . assertNoErrors ( ) ;
119
+ await shell . waitForSuccessfulExit ( ) ;
123
120
const deps = JSON . parse ( shell . output ) ;
124
121
expect ( deps . nodeDriverVersion ) . to . be . a ( 'string' ) ;
125
122
expect ( deps . libmongocryptVersion ) . to . be . a ( 'string' ) ;
@@ -176,34 +173,28 @@ describe('e2e', function () {
176
173
} ) ;
177
174
} ) ;
178
175
it ( 'closes the shell when "exit" is entered' , async function ( ) {
179
- const onExit = shell . waitForExit ( ) ;
180
176
shell . writeInputLine ( 'exit' ) ;
181
- expect ( await onExit ) . to . equal ( 0 ) ;
177
+ await shell . waitForSuccessfulExit ( ) ;
182
178
} ) ;
183
179
it ( 'closes the shell when "quit" is entered' , async function ( ) {
184
- const onExit = shell . waitForExit ( ) ;
185
180
shell . writeInputLine ( 'quit' ) ;
186
- expect ( await onExit ) . to . equal ( 0 ) ;
181
+ await shell . waitForSuccessfulExit ( ) ;
187
182
} ) ;
188
183
it ( 'closes the shell with the specified exit code when "exit(n)" is entered' , async function ( ) {
189
- const onExit = shell . waitForExit ( ) ;
190
184
shell . writeInputLine ( 'exit(42)' ) ;
191
- expect ( await onExit ) . to . equal ( 42 ) ;
185
+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 42 ) ;
192
186
} ) ;
193
187
it ( 'closes the shell with the specified exit code when "quit(n)" is entered' , async function ( ) {
194
- const onExit = shell . waitForExit ( ) ;
195
188
shell . writeInputLine ( 'quit(42)' ) ;
196
- expect ( await onExit ) . to . equal ( 42 ) ;
189
+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 42 ) ;
197
190
} ) ;
198
191
it ( 'closes the shell with the pre-specified exit code when "exit" is entered' , async function ( ) {
199
- const onExit = shell . waitForExit ( ) ;
200
192
shell . writeInputLine ( 'process.exitCode = 42; exit()' ) ;
201
- expect ( await onExit ) . to . equal ( 42 ) ;
193
+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 42 ) ;
202
194
} ) ;
203
195
it ( 'closes the shell with the pre-specified exit code when "quit" is entered' , async function ( ) {
204
- const onExit = shell . waitForExit ( ) ;
205
196
shell . writeInputLine ( 'process.exitCode = 42; quit()' ) ;
206
- expect ( await onExit ) . to . equal ( 42 ) ;
197
+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 42 ) ;
207
198
} ) ;
208
199
it ( 'decorates internal errors with bug reporting information' , async function ( ) {
209
200
const err = await shell . executeLine (
@@ -300,10 +291,8 @@ describe('e2e', function () {
300
291
'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' ,
301
292
{ end : true }
302
293
) ;
303
- const exitCode = await shell . waitForExit ( ) ;
304
- expect ( exitCode ) . to . equal ( 0 ) ;
294
+ await shell . waitForSuccessfulExit ( ) ;
305
295
shell . assertContainsOutput ( '3628800' ) ;
306
- shell . assertNoErrors ( ) ;
307
296
} ) ;
308
297
} ) ;
309
298
@@ -1095,9 +1084,8 @@ describe('e2e', function () {
1095
1084
'[db.hello()].reduce(\n() => { return 11111*11111; },0)\n\n\n' ,
1096
1085
{ end : true }
1097
1086
) ;
1098
- await shell . waitForExit ( ) ;
1087
+ await shell . waitForSuccessfulExit ( ) ;
1099
1088
shell . assertContainsOutput ( '123454321' ) ;
1100
- shell . assertNoErrors ( ) ;
1101
1089
} ) ;
1102
1090
} ) ;
1103
1091
@@ -1162,8 +1150,7 @@ describe('e2e', function () {
1162
1150
// when run under coverage, as we currently specify the location of
1163
1151
// coverage files via a relative path and nyc fails to write to that
1164
1152
// when started from a changed cwd.
1165
- await shell . waitForExit ( ) ;
1166
- shell . assertNoErrors ( ) ;
1153
+ await shell . waitForSuccessfulExit ( ) ;
1167
1154
} ) ;
1168
1155
1169
1156
if ( ! jsContextFlags . includes ( '--jsContext=plain-vm' ) ) {
@@ -1202,7 +1189,7 @@ describe('e2e', function () {
1202
1189
await eventually ( ( ) => {
1203
1190
shell . assertContainsOutput ( 'Error: uh oh' ) ;
1204
1191
} ) ;
1205
- expect ( await shell . waitForExit ( ) ) . to . equal ( 1 ) ;
1192
+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 1 ) ;
1206
1193
} ) ;
1207
1194
}
1208
1195
} ) ;
@@ -1216,8 +1203,7 @@ describe('e2e', function () {
1216
1203
await eventually ( ( ) => {
1217
1204
shell . assertContainsOutput ( 'hello one' ) ;
1218
1205
} ) ;
1219
- expect ( await shell . waitForExit ( ) ) . to . equal ( 0 ) ;
1220
- shell . assertNoErrors ( ) ;
1206
+ await shell . waitForSuccessfulExit ( ) ;
1221
1207
} ) ;
1222
1208
1223
1209
if ( ! jsContextFlags . includes ( '--jsContext=plain-vm' ) ) {
@@ -1244,7 +1230,7 @@ describe('e2e', function () {
1244
1230
await eventually ( ( ) => {
1245
1231
shell . assertContainsOutput ( 'Error: uh oh' ) ;
1246
1232
} ) ;
1247
- expect ( await shell . waitForExit ( ) ) . to . equal ( 1 ) ;
1233
+ expect ( await shell . waitForAnyExit ( ) ) . to . equal ( 1 ) ;
1248
1234
} ) ;
1249
1235
1250
1236
it ( 'fails with the error if the loaded script throws asynchronously (setImmediate)' , async function ( ) {
@@ -1259,7 +1245,7 @@ describe('e2e', function () {
1259
1245
await eventually ( ( ) => {
1260
1246
shell . assertContainsOutput ( 'Error: uh oh' ) ;
1261
1247
} ) ;
1262
- expect ( await shell . waitForExit ( ) ) . to . equal (
1248
+ expect ( await shell . waitForAnyExit ( ) ) . to . equal (
1263
1249
jsContextFlags . includes ( '--jsContext=repl' ) ? 0 : 1
1264
1250
) ;
1265
1251
} ) ;
@@ -1276,7 +1262,7 @@ describe('e2e', function () {
1276
1262
await eventually ( ( ) => {
1277
1263
shell . assertContainsOutput ( 'Error: uh oh' ) ;
1278
1264
} ) ;
1279
- expect ( await shell . waitForExit ( ) ) . to . equal (
1265
+ expect ( await shell . waitForAnyExit ( ) ) . to . equal (
1280
1266
jsContextFlags . includes ( '--jsContext=repl' ) ? 0 : 1
1281
1267
) ;
1282
1268
} ) ;
@@ -1299,7 +1285,7 @@ describe('e2e', function () {
1299
1285
script ,
1300
1286
] ,
1301
1287
} ) ;
1302
- expect ( await shell . waitForExit ( ) ) . to . equal ( 0 ) ;
1288
+ await shell . waitForSuccessfulExit ( ) ;
1303
1289
1304
1290
// Check that:
1305
1291
// - the script runs in the expected environment
@@ -1512,7 +1498,7 @@ describe('e2e', function () {
1512
1498
}
1513
1499
await shell . executeLine ( 'a = 42' ) ;
1514
1500
shell . writeInput ( '.exit\n' ) ;
1515
- await shell . waitForExit ( ) ;
1501
+ await shell . waitForSuccessfulExit ( ) ;
1516
1502
1517
1503
shell = await startTestShell ( ) ;
1518
1504
// Arrow up twice to skip the .exit line
@@ -1521,7 +1507,7 @@ describe('e2e', function () {
1521
1507
expect ( shell . output ) . to . include ( 'a = 42' ) ;
1522
1508
} ) ;
1523
1509
shell . writeInput ( '\n.exit\n' ) ;
1524
- await shell . waitForExit ( ) ;
1510
+ await shell . waitForSuccessfulExit ( ) ;
1525
1511
1526
1512
expect ( await fs . readFile ( historyPath , 'utf8' ) ) . to . match ( / ^ a = 4 2 $ / m) ;
1527
1513
} ) ;
@@ -1533,7 +1519,7 @@ describe('e2e', function () {
1533
1519
1534
1520
await shell . executeLine ( 'a = 42' ) ;
1535
1521
shell . writeInput ( '.exit\n' ) ;
1536
- await shell . waitForExit ( ) ;
1522
+ await shell . waitForSuccessfulExit ( ) ;
1537
1523
1538
1524
expect ( ( await fs . stat ( historyPath ) ) . mode & 0o077 ) . to . equal ( 0 ) ;
1539
1525
} ) ;
@@ -1544,7 +1530,7 @@ describe('e2e', function () {
1544
1530
await shell . executeLine ( 'a = 42' ) ;
1545
1531
await shell . executeLine ( 'foo = "bar"' ) ;
1546
1532
shell . writeInput ( '.exit\n' ) ;
1547
- await shell . waitForExit ( ) ;
1533
+ await shell . waitForAnyExit ( ) ; // db.auth() call fails because of --nodb
1548
1534
1549
1535
const contents = await fs . readFile ( historyPath , 'utf8' ) ;
1550
1536
expect ( contents ) . to . not . match ( / m y p a s s w o r d / ) ;
@@ -1603,7 +1589,7 @@ describe('e2e', function () {
1603
1589
`config.set("updateURL", ${ JSON . stringify ( httpServerUrl ) } )`
1604
1590
) ;
1605
1591
shell . writeInputLine ( 'exit' ) ;
1606
- await shell . waitForExit ( ) ;
1592
+ await shell . waitForSuccessfulExit ( ) ;
1607
1593
}
1608
1594
1609
1595
delete env . CI ;
@@ -1623,13 +1609,13 @@ describe('e2e', function () {
1623
1609
) . to . be . a ( 'string' ) ;
1624
1610
} ) ;
1625
1611
shell . writeInputLine ( 'exit' ) ;
1626
- await shell . waitForExit ( ) ;
1612
+ await shell . waitForSuccessfulExit ( ) ;
1627
1613
}
1628
1614
1629
1615
{
1630
1616
const shell = await startTestShell ( ) ;
1631
1617
shell . writeInputLine ( 'exit' ) ;
1632
- await shell . waitForExit ( ) ;
1618
+ await shell . waitForSuccessfulExit ( ) ;
1633
1619
shell . assertContainsOutput (
1634
1620
'mongosh 2023.4.15 is available for download: https://www.mongodb.com/try/download/shell'
1635
1621
) ;
@@ -1799,7 +1785,7 @@ describe('e2e', function () {
1799
1785
'.mongodb.net/' ,
1800
1786
] ,
1801
1787
} ) ;
1802
- const exitCode = await shell . waitForExit ( ) ;
1788
+ const exitCode = await shell . waitForAnyExit ( ) ;
1803
1789
expect ( exitCode ) . to . equal ( 1 ) ;
1804
1790
} ) ;
1805
1791
@@ -1813,7 +1799,7 @@ describe('e2e', function () {
1813
1799
'.mongodb.net/' ,
1814
1800
] ,
1815
1801
} ) ;
1816
- const exitCode = await shell . waitForExit ( ) ;
1802
+ const exitCode = await shell . waitForAnyExit ( ) ;
1817
1803
expect ( exitCode ) . to . equal ( 1 ) ;
1818
1804
} ) ;
1819
1805
@@ -1904,7 +1890,7 @@ describe('e2e', function () {
1904
1890
) ;
1905
1891
1906
1892
shell . writeInputLine ( 'exit' ) ;
1907
- await shell . waitForExit ( ) ;
1893
+ await shell . waitForSuccessfulExit ( ) ;
1908
1894
shell . assertNoErrors ( ) ;
1909
1895
} ) ;
1910
1896
} ) ;
@@ -1937,7 +1923,7 @@ describe('e2e', function () {
1937
1923
args : [ filename ] ,
1938
1924
env : { ...process . env , MONGOSH_RUN_NODE_SCRIPT : '1' } ,
1939
1925
} ) ;
1940
- expect ( await shell . waitForExit ( ) ) . to . equal ( 0 ) ;
1926
+ await shell . waitForSuccessfulExit ( ) ;
1941
1927
shell . assertContainsOutput ( '610' ) ;
1942
1928
} ) ;
1943
1929
} ) ;
0 commit comments