Skip to content

Commit c4245b6

Browse files
committed
add test cases
1 parent e7b2478 commit c4245b6

21 files changed

Lines changed: 110 additions & 513 deletions

File tree

src/spec-node/dockerfilePreprocessor.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ export async function preprocessDockerExtensionFile(
4949
const inputPath = dockerfilePath;
5050
const outputPath = cliOutputPath;
5151
const generatedOutputPath = generatedDockerfile ? path.resolve(workdirPath, generatedDockerfile) : outputPath;
52+
const staleOutputPaths = generatedOutputPath === outputPath ? [outputPath] : [outputPath, generatedOutputPath];
53+
for (const stalePath of staleOutputPaths) {
54+
if (!await cliHost.isFile(stalePath)) {
55+
continue;
56+
}
57+
const cleanupCommand = cliHost.platform === 'win32'
58+
? { cmd: 'cmd', args: ['/d', '/s', '/c', `del /f /q "${stalePath}"`] }
59+
: { cmd: 'rm', args: ['-f', stalePath] };
60+
await runCommandNoPty({
61+
exec: cliHost.exec,
62+
cmd: cleanupCommand.cmd,
63+
args: cleanupCommand.args,
64+
cwd: workdirPath,
65+
env: cliHost.env,
66+
output: infoOutput,
67+
});
68+
}
5269

5370
// Strict contract: the CLI owns the final output path. Direct-transform
5471
// tools can write to the CLI-provided output argument; workspace generators
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Docker Compose Cpp Preprocessor",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspace",
6+
"dockerfilePreprocessor": {
7+
"tool": "cpp",
8+
"outputMode": "single-file",
9+
"args": [
10+
"-P"
11+
]
12+
},
13+
"features": {
14+
"ghcr.io/devcontainers/features/github-cli:1": {
15+
"version": "latest"
16+
}
17+
}
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: ..
7+
dockerfile: Dockerfile.in
8+
command: sleep infinity
9+
volumes:
10+
- ..:/workspace:cached
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#define BASE_IMAGE ubuntu:20.04
2+
#define INSTALL_NODE
3+
#define INSTALL_PYTHON
4+
5+
FROM BASE_IMAGE
6+
7+
#ifdef INSTALL_NODE
8+
RUN apt-get update && apt-get install -y nodejs
9+
#endif
10+
11+
#ifdef INSTALL_PYTHON
12+
RUN apt-get update && apt-get install -y python3
13+
#endif
14+
15+
#include "common.Dockerfile"
16+
#include "tools.Dockerfile"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RUN apt-get update && apt-get install -y curl wget
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
echo hello
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RUN apt-get update && apt-get install -y vim
2+
COPY ./test.sh /usr/local/bin/test.sh

src/test/configs/dockerfile-autoconf-preprocessor/.devcontainer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"dockerfile": "Dockerfile.in"
44
},
55
"dockerfilePreprocessor": {
6-
"commands": [
7-
"autoconf",
8-
"./configure"
6+
"tool": "sh",
7+
"args": [
8+
"-c",
9+
"autoconf && ./configure"
910
],
10-
"output": "Dockerfile"
11+
"generatedDockerfile": "Dockerfile"
1112
},
1213
"features": {
1314
"ghcr.io/devcontainers/features/github-cli:1": {

src/test/configs/dockerfile-cmake-preprocessor/.devcontainer-preprocessed/Dockerfile

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/test/configs/dockerfile-cmake-preprocessor/build/CMakeCache.txt

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)