@@ -88,6 +88,7 @@ export async function runSmokeTests({
8888 tags,
8989 input,
9090 output,
91+ env,
9192 testArgs,
9293 includeStderr,
9394 exitCode,
@@ -120,6 +121,19 @@ export async function runSmokeTests({
120121 exitCode : 0 ,
121122 perfTestIterations : 0 ,
122123 } ,
124+ {
125+ // Regression test for MONGOSH-2233, included here because multiline support is a bit
126+ // more fragile when it comes to newer Node.js releases and these are the only tests
127+ // that run as part of the homebrew setup.
128+ name : 'print_multiline_terminal' ,
129+ input : [ '{' , 'print("He" + "llo" +' , '" Wor" + "ld!")' , '}' ] ,
130+ env : { MONGOSH_FORCE_TERMINAL : 'true' } ,
131+ output : / H e l l o W o r l d ! / ,
132+ includeStderr : false ,
133+ testArgs : [ '--nodb' ] ,
134+ exitCode : 0 ,
135+ perfTestIterations : 0 ,
136+ } ,
123137 {
124138 name : 'eval_nodb_print_plainvm' ,
125139 input : '' ,
@@ -313,7 +327,11 @@ export async function runSmokeTests({
313327 os . tmpdir ( ) ,
314328 `mongosh_smoke_test_${ name } _${ Date . now ( ) } .js`
315329 ) ;
316- await fs . writeFile ( tmpfile , input , { mode : 0o600 , flag : 'wx' } ) ;
330+ await fs . writeFile (
331+ tmpfile ,
332+ Array . isArray ( input ) ? input . join ( '\n' ) : input ,
333+ { mode : 0o600 , flag : 'wx' }
334+ ) ;
317335 cleanup . unshift ( async ( ) => await fs . unlink ( tmpfile ) ) ;
318336 testArgs [ index ] = arg . replace ( '$INPUT_AS_FILE' , tmpfile ) ;
319337 actualInput = '' ;
@@ -326,6 +344,7 @@ export async function runSmokeTests({
326344 args : [ ...args , ...testArgs ] ,
327345 input : actualInput ,
328346 output,
347+ env,
329348 includeStderr,
330349 exitCode,
331350 printSuccessResults : ! wantPerformanceTesting ,
@@ -377,6 +396,7 @@ async function runSmokeTest({
377396 name,
378397 executable,
379398 args,
399+ env,
380400 input,
381401 output,
382402 exitCode,
@@ -386,7 +406,8 @@ async function runSmokeTest({
386406 name : string ;
387407 executable : string ;
388408 args : string [ ] ;
389- input : string ;
409+ env ?: Record < string , string | undefined > ;
410+ input : string | string [ ] ;
390411 output : RegExp ;
391412 exitCode ?: number ;
392413 includeStderr ?: boolean ;
@@ -398,6 +419,7 @@ async function runSmokeTest({
398419 const { spawn } = require ( 'child_process' ) as typeof import ( 'child_process' ) ;
399420 const proc = spawn ( executable , [ ...args ] , {
400421 stdio : 'pipe' ,
422+ env : { ...process . env , ...env } ,
401423 } ) ;
402424 let stdout = '' ;
403425 let stderr = '' ;
@@ -407,7 +429,14 @@ async function runSmokeTest({
407429 proc . stderr ?. setEncoding ( 'utf8' ) . on ( 'data' , ( chunk ) => {
408430 stderr += chunk ;
409431 } ) ;
410- proc . stdin ! . end ( input ) ;
432+ if ( Array . isArray ( input ) ) {
433+ for ( const chunk of input ) {
434+ proc . stdin ! . write ( chunk + '\n' ) ;
435+ }
436+ proc . stdin ! . end ( ) ;
437+ } else {
438+ proc . stdin ! . end ( input ) ;
439+ }
411440 const [ [ actualExitCode ] ] = await Promise . all ( [
412441 once ( proc , 'exit' ) ,
413442 once ( proc . stdout ! , 'end' ) ,
0 commit comments