diff --git a/src/test/cli.build.test.ts b/src/test/cli.build.test.ts index a6c17f5a9..b1a2a9e32 100644 --- a/src/test/cli.build.test.ts +++ b/src/test/cli.build.test.ts @@ -260,11 +260,5 @@ describe('Dev Containers CLI', function () { const details = JSON.parse((await shellExec(`docker inspect test-subfolder-config`)).stdout)[0] as ImageDetails; assert.strictEqual(envListToObj(details.Config.Env).SUBFOLDER_CONFIG_IMAGE_ENV, 'true'); }); - - it('should build with a local feature', async () => { - const res = await shellExec(`${cli} build --workspace-folder ${__dirname}/configs/image-with-local-feature --image-name test-local-feature`) - const response = JSON.parse(res.stdout); - assert.strictEqual(response.outcome, 'success'); - }); }); }); \ No newline at end of file diff --git a/src/test/configs/image-with-local-feature/.devcontainer/devcontainer.json b/src/test/container-features/configs/image-with-local-feature/.devcontainer/devcontainer.json similarity index 100% rename from src/test/configs/image-with-local-feature/.devcontainer/devcontainer.json rename to src/test/container-features/configs/image-with-local-feature/.devcontainer/devcontainer.json diff --git a/src/test/configs/image-with-local-feature/.devcontainer/test-feature/devcontainer-feature.json b/src/test/container-features/configs/image-with-local-feature/.devcontainer/test-feature/devcontainer-feature.json similarity index 76% rename from src/test/configs/image-with-local-feature/.devcontainer/test-feature/devcontainer-feature.json rename to src/test/container-features/configs/image-with-local-feature/.devcontainer/test-feature/devcontainer-feature.json index f2da6e155..3a8b63cfd 100644 --- a/src/test/configs/image-with-local-feature/.devcontainer/test-feature/devcontainer-feature.json +++ b/src/test/container-features/configs/image-with-local-feature/.devcontainer/test-feature/devcontainer-feature.json @@ -10,5 +10,6 @@ "target": "/home/${remoteUser}", "type": "volume" } - ] + ], + "postCreateCommand": "/usr/bin/whoami && echo ${remoteUser} > /tmp/variable-substitution.testMarker" } \ No newline at end of file diff --git a/src/test/configs/image-with-local-feature/.devcontainer/test-feature/install.sh b/src/test/container-features/configs/image-with-local-feature/.devcontainer/test-feature/install.sh similarity index 100% rename from src/test/configs/image-with-local-feature/.devcontainer/test-feature/install.sh rename to src/test/container-features/configs/image-with-local-feature/.devcontainer/test-feature/install.sh diff --git a/src/test/container-features/lifecycleHooks.test.ts b/src/test/container-features/lifecycleHooks.test.ts index 325d2b900..af3de8664 100644 --- a/src/test/container-features/lifecycleHooks.test.ts +++ b/src/test/container-features/lifecycleHooks.test.ts @@ -371,6 +371,38 @@ describe('Feature lifecycle hooks', function () { }); }); + describe('lifecycle-hooks-with-variable-substitution', () => { + describe('devcontainer up', () => { + let containerId: string | null = null; + let containerUpStandardError: string; + const testFolder = `${__dirname}/configs/image-with-local-feature`; + + before(async () => { + await shellExec(`rm -f ${testFolder}/*.testMarker`, undefined, undefined, true); + const res = await devContainerUp(cli, testFolder, { 'logLevel': 'trace' }); + containerId = res.containerId; + containerUpStandardError = res.stderr; + }); + + after(async () => { + await devContainerDown({ containerId }); + await shellExec(`rm -f ${testFolder}/*.testMarker`, undefined, undefined, true); + }); + + it('executes lifecycle hooks with variable substitution', async () => { + const res = await shellExec(`${cli} exec --workspace-folder ${testFolder} cat /tmp/variable-substitution.testMarker`); + assert.strictEqual(res.error, null); + + const outputOfExecCommand = res.stdout; + console.log(outputOfExecCommand); + + // Executes the command that was installed by the local Feature's 'postCreateCommand'. + assert.match(outputOfExecCommand, /vscode/); + assert.match(containerUpStandardError, /Running the postCreateCommand from Feature '.\/test-feature/); + }); + }); + }); + describe('lifecycle-hooks-advanced', () => { describe(`devcontainer up`, () => {