Skip to content

Commit 83b9ad4

Browse files
aledbfclaude
andcommitted
test(parity): lock the cases whose setup writes Features
TestParityMatrixLocksTheFeatureContentImage read Features only from fixture configurations, so 13 cases whose setup_cmd writes a configuration with Features and builds it without BuildKit ran without the feature-content-image lock and could take each other's Features through dev_container_feature_content_temp. The check now also reads the configuration a setup_cmd writes, and those cases hold the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent dbdf8e5 commit 83b9ad4

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎docs/parity/parity-matrix.yaml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ initial_cases:
780780
notes: "TS builds a Dockerfile service through a build override even without Features (getImageBuildOptions adds the devcontainer.metadata label to the image) and then runs updateRemoteUserUID on the built image (dockerCompose.ts startContainer). Go built the service unchanged and never remapped the remote user's UID for compose."
781781

782782
- id: up.compose-image-with-local-feature-image-name-success
783+
lock: feature-content-image
783784
lane: runtime
784785
command: up
785786
priority: p1
@@ -907,6 +908,7 @@ initial_cases:
907908
notes: "BuildKit Features build (TS getFeaturesBuildOptions + getFeatureLayers, containerFeaturesConfiguration.ts): the Feature is staged at its consecutiveId (hello_0), bind-mounted from the dev_containers_feature_content_source build context, copied to /tmp/dev-container-features/hello_0 and installed through devcontainer-features-install.sh, which sources ../devcontainer-features.builtin.env (_CONTAINER_USER/_REMOTE_USER plus the _*_HOME lines the first RUN appends) and devcontainer-features.env (options in devcontainer-feature.json order); the folder is removed afterwards, the builtin env stays. The Feature's containerEnv and the config's containerEnv are ENV lines and the image keeps its own user (USER $_DEV_CONTAINERS_IMAGE_USER). Go used to copy _dev_container_feature_0 to /tmp/build-features and run install.sh with inline env prefixes, so ../devcontainer-features.builtin.env did not exist."
908909

909910
- id: build.features-staging-layout-no-buildkit-success
911+
lock: feature-content-image
910912
lane: runtime
911913
command: build
912914
priority: p1
@@ -1098,6 +1100,7 @@ initial_cases:
10981100
notes: "A compose configuration without workspaceFolder works in `/` (TS getWorkspaceConfiguration returns getRemoteWorkspaceFolder, `config.workspaceFolder || '/'`, dockerCompose.ts): up's remoteWorkspaceFolder, ${containerWorkspaceFolder}, the lifecycle commands' cwd and exec's cwd. Go used /workspaces/<basename>, a folder the compose service never mounts."
10991101

11001102
- id: build.frozen-lockfile-missing-failure
1103+
lock: feature-content-image
11011104
lane: runtime
11021105
command: build
11031106
priority: p1
@@ -1111,6 +1114,7 @@ initial_cases:
11111114
notes: "--frozen-lockfile without a lockfile fails with TS writeLockfile's 'Lockfile does not exist.' (lockfile.ts), wrapped as the build's ContainerError: message is that text, description 'An error occurred building the container.'. Go skipped the check when no lockfile existed and built the image."
11121115

11131116
- id: up.frozen-lockfile-mismatch-failure
1117+
lock: feature-content-image
11141118
lane: runtime
11151119
command: up
11161120
priority: p1
@@ -1124,6 +1128,7 @@ initial_cases:
11241128
notes: "A stale lockfile with --frozen-lockfile fails with TS's 'Lockfile does not match.' as the message and 'An error occurred setting up the container.' as the description. Go reported 'An error occurred setting up the container: install features: lockfile: lockfile does not match' in both."
11251129

11261130
- id: up.compose-frozen-lockfile-missing-failure
1131+
lock: feature-content-image
11271132
lane: runtime
11281133
command: up
11291134
priority: p1
@@ -1151,6 +1156,7 @@ initial_cases:
11511156
notes: "JSON.stringify writes properties in insertion order: the result as readConfiguration's literal lists them, the configuration in its document's order with configFilePath last, featuresConfiguration as FeaturesConfig's literal (featureSets, dstFolder), mergedConfiguration as mergeConfiguration builds it (the configuration without replaceProperties, then the properties it sets). Go wrote every object with sorted keys. Nested user objects keep sorted keys (docs/DIVERGENCES.md)."
11521157

11531158
- id: up.include-configurations-key-order-success
1159+
lock: feature-content-image
11541160
lane: runtime
11551161
command: up
11561162
priority: p1
@@ -1271,6 +1277,7 @@ initial_cases:
12711277
notes: "up mounts the additionalMountString read-configuration reports: TS spawnDevContainer passes it as a --mount after the workspace mount (singleContainer.ts), so the container has the worktree and its common dir."
12721278

12731279
- id: build.lockfile-written-by-default-success
1280+
lock: feature-content-image
12741281
lane: runtime
12751282
command: build
12761283
priority: p1
@@ -1287,6 +1294,7 @@ initial_cases:
12871294
notes: "TS writes devcontainer-lock.json on every build with Features unless --no-lockfile is given (containerFeaturesConfiguration.ts generateFeaturesConfig -> writeLockfile, which creates the file); it records the OCI Feature, pinned to its digest, and leaves the local one out. Go wrote it only with --experimental-lockfile or --frozen-lockfile."
12881295

12891296
- id: build.no-lockfile-writes-none-success
1297+
lock: feature-content-image
12901298
lane: runtime
12911299
command: build
12921300
priority: p1
@@ -1302,6 +1310,7 @@ initial_cases:
13021310
notes: "--no-lockfile disables writing the lockfile (generateFeaturesConfig skips writeLockfile): the configuration folder holds no devcontainer-lock.json after the build."
13031311

13041312
- id: build.dot-devcontainer-lockfile-path-success
1313+
lock: feature-content-image
13051314
lane: runtime
13061315
command: build
13071316
priority: p1
@@ -1316,6 +1325,7 @@ initial_cases:
13161325
notes: "A .devcontainer.json gets .devcontainer-lock.json next to it (lockfile.ts getLockfilePath); with only a local Feature (under .devcontainer/, where TS requires it) the lockfile's features map is empty, and TS still writes it."
13171326

13181327
- id: up.lockfile-rewrites-stale-success
1328+
lock: feature-content-image
13191329
lane: runtime
13201330
command: up
13211331
priority: p1
@@ -1332,6 +1342,7 @@ initial_cases:
13321342
notes: "up rewrites a stale lockfile with the resolved Features by default (writeLockfile replaces content whose JSON.parse -> JSON.stringify differs). Go left an existing lockfile alone without a lockfile flag."
13331343

13341344
- id: up.no-lockfile-leaves-lockfile-success
1345+
lock: feature-content-image
13351346
lane: runtime
13361347
command: up
13371348
priority: p1
@@ -1346,6 +1357,7 @@ initial_cases:
13461357
notes: "--no-lockfile neither reads nor writes the lockfile: a stale one is left as it was."
13471358

13481359
- id: up.compose-lockfile-written-by-default-success
1360+
lock: feature-content-image
13491361
lane: runtime
13501362
command: up
13511363
priority: p1
@@ -1362,6 +1374,7 @@ initial_cases:
13621374
notes: "The Compose path resolves the Features through the same generateFeaturesConfig (dockerCompose.ts -> getExtendImageBuildInfo) and writes the lockfile by default. Go wrote it only with a lockfile flag."
13631375

13641376
- id: build.compose-no-lockfile-writes-none-success
1377+
lock: feature-content-image
13651378
lane: runtime
13661379
command: build
13671380
priority: p1

‎internal/cli/parity_lock_test.go‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ var (
1515
parityWorkspaceFlag = regexp.MustCompile(`--workspace-folder\s+(src/test/configs/[^\s"';]+)`)
1616
parityConfigFlag = regexp.MustCompile(`--config\s+(src/test/configs/[^\s"';]+)`)
1717
nonEmptyFeaturesJSON = regexp.MustCompile(`"features"\s*:\s*\{\s*"`)
18+
// setupWritesFeatures matches a setup_cmd that writes a configuration with
19+
// Features itself, its quotes possibly escaped for the shell.
20+
setupWritesFeatures = regexp.MustCompile(`\\?"features\\?"\s*:\s*\{\s*\\?"`)
1821
)
1922

20-
// A case that builds Features without BuildKit goes through the shared
23+
// A case that builds Features without BuildKit, from a fixture or from a
24+
// configuration its setup_cmd writes, goes through the shared
2125
// dev_container_feature_content_temp image, so it must hold the
2226
// feature-content-image lock; a case that does not, must not, so the lock
2327
// serializes no more than it has to.
@@ -36,13 +40,13 @@ func TestParityMatrixLocksTheFeatureContentImage(t *testing.T) {
3640
t.Errorf("case %q names unknown lock %q", tc.ID, tc.Lock)
3741
}
3842
cmds := tc.TSCmd + "\n" + tc.SetupCmd
39-
need := strings.Contains(cmds, "--buildkit=never") && slices.ContainsFunc(parityCaseConfigs(t, cmds), func(config string) bool {
43+
need := strings.Contains(cmds, "--buildkit=never") && (setupWritesFeatures.MatchString(tc.SetupCmd) || slices.ContainsFunc(parityCaseConfigs(t, cmds), func(config string) bool {
4044
data, err := os.ReadFile(filepath.Join("..", "..", config))
4145
if err != nil {
4246
t.Fatalf("case %q: %v", tc.ID, err)
4347
}
4448
return nonEmptyFeaturesJSON.Match(data)
45-
})
49+
}))
4650
switch has := tc.Lock == "feature-content-image"; {
4751
case need && !has:
4852
t.Errorf("case %q builds Features without BuildKit; add `lock: feature-content-image`", tc.ID)

0 commit comments

Comments
 (0)