@@ -3,6 +3,7 @@ import { mkdirSync, unlinkSync, writeFileSync } from "node:fs";
33import path from "node:path" ;
44import { afterEach , describe , expect , it } from "vitest" ;
55import {
6+ createEmptyChangedLanes ,
67 detectChangedLanes ,
78 isLiveDockerPackageScriptOnlyChange ,
89 isPackageScriptOnlyChange ,
@@ -46,6 +47,23 @@ const git = (cwd: string, args: string[]) =>
4647 env : createNestedGitEnv ( ) ,
4748 } ) . trim ( ) ;
4849
50+ function expectLanes (
51+ lanes : ReturnType < typeof createEmptyChangedLanes > ,
52+ expected : Partial < ReturnType < typeof createEmptyChangedLanes > > ,
53+ ) {
54+ expect ( lanes ) . toEqual ( { ...createEmptyChangedLanes ( ) , ...expected } ) ;
55+ }
56+
57+ function parseChangedLaneOutput ( output : string ) : {
58+ paths : string [ ] ;
59+ lanes : ReturnType < typeof createEmptyChangedLanes > ;
60+ } {
61+ return JSON . parse ( output ) as {
62+ paths : string [ ] ;
63+ lanes : ReturnType < typeof createEmptyChangedLanes > ;
64+ } ;
65+ }
66+
4967afterEach ( ( ) => {
5068 cleanupTempDirs ( tempDirs ) ;
5169} ) ;
@@ -80,10 +98,10 @@ describe("scripts/changed-lanes", () => {
8098 } ,
8199 ) ;
82100
83- expect ( JSON . parse ( output ) ) . toMatchObject ( {
84- paths : [ "scripts/new-check.mjs" ] ,
85- lanes : { tooling : true } ,
86- } ) ;
101+ const result = parseChangedLaneOutput ( output ) ;
102+
103+ expect ( result . paths ) . toEqual ( [ "scripts/new-check.mjs" ] ) ;
104+ expectLanes ( result . lanes , { tooling : true } ) ;
87105 } ) ;
88106
89107 it ( "includes deleted worktree files in the default local diff" , ( ) => {
@@ -119,10 +137,10 @@ describe("scripts/changed-lanes", () => {
119137 } ,
120138 ) ;
121139
122- expect ( JSON . parse ( output ) ) . toMatchObject ( {
123- paths : [ "src/shared/obsolete.ts" ] ,
124- lanes : { core : true , coreTests : true } ,
125- } ) ;
140+ const result = parseChangedLaneOutput ( output ) ;
141+
142+ expect ( result . paths ) . toEqual ( [ "src/shared/obsolete.ts" ] ) ;
143+ expectLanes ( result . lanes , { core : true , coreTests : true } ) ;
126144 } ) ;
127145
128146 it ( "includes deleted staged files in the staged diff" , ( ) => {
@@ -159,10 +177,10 @@ describe("scripts/changed-lanes", () => {
159177 } ,
160178 ) ;
161179
162- expect ( JSON . parse ( output ) ) . toMatchObject ( {
163- paths : [ "src/shared/obsolete.ts" ] ,
164- lanes : { core : true , coreTests : true } ,
165- } ) ;
180+ const result = parseChangedLaneOutput ( output ) ;
181+
182+ expect ( result . paths ) . toEqual ( [ "src/shared/obsolete.ts" ] ) ;
183+ expectLanes ( result . lanes , { core : true , coreTests : true } ) ;
166184 } ) ;
167185
168186 it ( "ignores the explicit path separator" , ( ) => {
@@ -177,22 +195,24 @@ describe("scripts/changed-lanes", () => {
177195 const result = detectChangedLanes ( [ "src/shared/string-normalization.ts" ] ) ;
178196 const plan = createChangedCheckPlan ( result , { env : { PATH : "/usr/bin" } } ) ;
179197
180- expect ( result . lanes ) . toMatchObject ( {
198+ expectLanes ( result . lanes , {
181199 core : true ,
182200 coreTests : true ,
183- extensions : false ,
184- extensionTests : false ,
185- all : false ,
186201 } ) ;
187202 expect ( plan . commands . map ( ( command ) => command . args [ 0 ] ) ) . toContain ( "tsgo:core" ) ;
188203 expect ( plan . commands . map ( ( command ) => command . args [ 0 ] ) ) . toContain ( "tsgo:core:test" ) ;
189- expect ( plan . commands . find ( ( command ) => command . args [ 0 ] === "tsgo:core" ) ?. env ) . toMatchObject ( {
204+ expect ( plan . commands . find ( ( command ) => command . args [ 0 ] === "tsgo:core" ) ?. env ) . toEqual ( {
190205 PATH : "/usr/bin" ,
206+ OPENCLAW_OXLINT_SKIP_LOCK : "1" ,
207+ OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD : "1" ,
208+ OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD : "1" ,
191209 OPENCLAW_TSGO_SPARSE_SKIP : "1" ,
192210 } ) ;
193- expect ( plan . commands . find ( ( command ) => command . args [ 0 ] === "lint:core" ) ?. env ) . toMatchObject ( {
211+ expect ( plan . commands . find ( ( command ) => command . args [ 0 ] === "lint:core" ) ?. env ) . toEqual ( {
194212 PATH : "/usr/bin" ,
195213 OPENCLAW_OXLINT_SKIP_LOCK : "1" ,
214+ OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD : "1" ,
215+ OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD : "1" ,
196216 } ) ;
197217 } ) ;
198218
@@ -202,15 +222,18 @@ describe("scripts/changed-lanes", () => {
202222 env : { OPENCLAW_LOCAL_CHECK : "0" , PATH : "/usr/bin" } ,
203223 } ) ;
204224
205- expect ( plan . commands . find ( ( command ) => command . args [ 0 ] === "tsgo:core" ) ?. env ) . toMatchObject ( {
225+ expect ( plan . commands . find ( ( command ) => command . args [ 0 ] === "tsgo:core" ) ?. env ) . toEqual ( {
206226 OPENCLAW_LOCAL_CHECK : "1" ,
227+ OPENCLAW_OXLINT_SKIP_LOCK : "1" ,
228+ OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD : "1" ,
229+ OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD : "1" ,
207230 OPENCLAW_TSGO_SPARSE_SKIP : "1" ,
208231 PATH : "/usr/bin" ,
209232 } ) ;
210233 } ) ;
211234
212235 it ( "marks changed-check children as covered by the parent heavy-check lock" , ( ) => {
213- expect ( createChangedCheckChildEnv ( { PATH : "/usr/bin" } ) ) . toMatchObject ( {
236+ expect ( createChangedCheckChildEnv ( { PATH : "/usr/bin" } ) ) . toEqual ( {
214237 OPENCLAW_OXLINT_SKIP_LOCK : "1" ,
215238 OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD : "1" ,
216239 OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD : "1" ,
0 commit comments