@@ -266,6 +266,40 @@ describe('Dev Containers CLI', function () {
266266 await shellExec ( `docker rm -f ${ containerId } ` ) ;
267267 } ) ;
268268
269+ it ( 'should follow the correct merge logic for containerEnv using docker compose' , async ( ) => {
270+ const res = await shellExec ( `${ cli } up --workspace-folder ${ __dirname } /configs/image-containerEnv-issue` ) ;
271+ const response = JSON . parse ( res . stdout ) ;
272+ assert . equal ( response . outcome , 'success' ) ;
273+ const containerId : string = response . containerId ;
274+ assert . ok ( containerId , 'Container id not found.' ) ;
275+
276+ const somePath = await shellExec ( `docker exec ${ containerId } bash -c 'echo -n $SOME_PATH'` ) ;
277+ assert . equal ( '/tmp/path/doc-ver/loc' , somePath . stdout ) ;
278+
279+ const envWithSpaces = await shellExec ( `docker exec ${ containerId } bash -c 'echo -n $VAR_WITH_SPACES'` ) ;
280+ assert . equal ( 'value with spaces' , envWithSpaces . stdout ) ;
281+
282+ const evalEnvWithCommand = await shellExec ( `docker exec ${ containerId } bash -c 'eval $ENV_WITH_COMMAND'` ) ;
283+ assert . equal ( 'Hello, World!' , evalEnvWithCommand . stdout ) ;
284+
285+ const envWithTestMessage = await shellExec ( `docker exec ${ containerId } bash -c 'echo -n $Test_Message'` ) ;
286+ assert . equal ( 'H"\\n\\ne"\'\'\'llo M:;a/t?h&^iKa%#@!``ni,sk_a-' , envWithTestMessage . stdout ) ;
287+
288+ const envWithFormat = await shellExec ( `docker exec ${ containerId } bash -c 'echo -n $ROSCONSOLE_FORMAT'` ) ;
289+ assert . equal ( '[$${severity}] [$${walltime:%Y-%m-%d %H:%M:%S}] [$${node}]: $${message}' , envWithFormat . stdout ) ;
290+
291+ const envWithDoubleQuote = await shellExec ( `docker exec ${ containerId } bash -c 'echo -n $VAR_WITH_QUOTES_WE_WANT_TO_KEEP'` ) ;
292+ assert . equal ( 'value with \"quotes\" we want to keep' , envWithDoubleQuote . stdout ) ;
293+
294+ const envWithDollar = await shellExec ( `docker exec ${ containerId } bash -c 'echo -n $VAR_WITH_DOLLAR_SIGN'` ) ;
295+ assert . equal ( 'value with $dollar sign' , envWithDollar . stdout ) ;
296+
297+ const envWithBackSlash = await shellExec ( `docker exec ${ containerId } bash -c 'echo -n $VAR_WITH_BACK_SLASH'` ) ;
298+ assert . equal ( 'value with \\back slash' , envWithBackSlash . stdout ) ;
299+
300+ await shellExec ( `docker rm -f ${ containerId } ` ) ;
301+ } ) ;
302+
269303 it ( 'should run with config in subfolder' , async ( ) => {
270304 const upRes = await shellExec ( `${ cli } up --workspace-folder ${ __dirname } /configs/dockerfile-without-features --config ${ __dirname } /configs/dockerfile-without-features/.devcontainer/subfolder/devcontainer.json` ) ;
271305 const response = JSON . parse ( upRes . stdout ) ;
0 commit comments