@@ -530,13 +530,18 @@ type UpdateCliScenario = {
530530} ;
531531
532532describe ( "update-cli" , ( ) => {
533- const fixtureRoot = "/tmp/openclaw-update-tests" ;
533+ // Per-run unique root: concurrent runs on one machine (CI shards, sibling checkouts) must
534+ // never share fixture paths — some cases write real files and rm them in cleanup. Realpath'd
535+ // because macOS os.tmpdir() is a /var -> /private/var symlink.
536+ const fixtureRoot = fsSync . realpathSync (
537+ fsSync . mkdtempSync ( path . join ( os . tmpdir ( ) , "openclaw-update-tests-" ) ) ,
538+ ) ;
534539 let fixtureCount = 0 ;
535540 const tempDirsToCleanup = new Set < string > ( ) ;
536541
537542 const createCaseDir = ( prefix : string ) => {
538543 const dir = path . join ( fixtureRoot , `${ prefix } -${ fixtureCount ++ } ` ) ;
539- // Tests only need a stable path; the directory does not have to exist because all I/O is mocked .
544+ // Callers that only need a stable path skip creating it; real- I/O callers mkdir themselves .
540545 return dir ;
541546 } ;
542547
@@ -1487,8 +1492,9 @@ describe("update-cli", () => {
14871492 setStdoutTty ( false ) ;
14881493 } ) ;
14891494
1490- afterAll ( ( ) => {
1495+ afterAll ( async ( ) => {
14911496 serviceEnvSnapshot . restore ( ) ;
1497+ await fs . rm ( fixtureRoot , { recursive : true , force : true } ) ;
14921498 } ) ;
14931499
14941500 afterEach ( async ( ) => {
@@ -1668,7 +1674,8 @@ describe("update-cli", () => {
16681674 candidate === path . join ( root , "package.json" ) ||
16691675 entrypoints . includes ( candidate ) ,
16701676 ) ;
1671- const managedState = "/tmp/openclaw-update-tests/managed-profile" ;
1677+ const managedState = path . join ( fixtureRoot , "managed-profile" ) ;
1678+ const personalState = path . join ( fixtureRoot , "personal-profile" ) ;
16721679 const managedConfig = {
16731680 ...baseConfig ,
16741681 update : { channel : "beta" as const } ,
@@ -1723,8 +1730,8 @@ describe("update-cli", () => {
17231730 await withEnvAsync (
17241731 {
17251732 OPENCLAW_PROFILE : "personal" ,
1726- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/personal-profile" ,
1727- OPENCLAW_CONFIG_PATH : "/tmp/ openclaw-update-tests/personal-profile/openclaw .json",
1733+ OPENCLAW_STATE_DIR : personalState ,
1734+ OPENCLAW_CONFIG_PATH : path . join ( personalState , " openclaw.json") ,
17281735 OPENCLAW_GATEWAY_PORT : "19111" ,
17291736 } ,
17301737 async ( ) => {
@@ -1746,6 +1753,7 @@ describe("update-cli", () => {
17461753 } ) ;
17471754
17481755 it ( "keeps foreign-service updates in the caller profile" , async ( ) => {
1756+ const personalState = path . join ( fixtureRoot , "personal-profile" ) ;
17491757 const { root, entrypoints } = setupUpdatedRootRefresh ( ) ;
17501758 const foreignRoot = await createTrackedTempDir ( "openclaw-update-foreign-profile-" ) ;
17511759 const foreignEntrypoint = path . join ( foreignRoot , "dist" , "index.js" ) ;
@@ -1768,7 +1776,7 @@ describe("update-cli", () => {
17681776 programArguments : [ "node" , foreignEntrypoint , "gateway" , "run" ] ,
17691777 environment : {
17701778 OPENCLAW_PROFILE : "foreign" ,
1771- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/ foreign-profile",
1779+ OPENCLAW_STATE_DIR : path . join ( fixtureRoot , " foreign-profile") ,
17721780 OPENCLAW_GATEWAY_PORT : "19333" ,
17731781 } ,
17741782 } ) ;
@@ -1782,7 +1790,7 @@ describe("update-cli", () => {
17821790 await withEnvAsync (
17831791 {
17841792 OPENCLAW_PROFILE : "personal" ,
1785- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/personal-profile" ,
1793+ OPENCLAW_STATE_DIR : personalState ,
17861794 OPENCLAW_GATEWAY_PORT : "19111" ,
17871795 } ,
17881796 async ( ) => {
@@ -1794,7 +1802,7 @@ describe("update-cli", () => {
17941802 expect ( serviceEnabled ) . not . toHaveBeenCalled ( ) ;
17951803 expect ( spawnCall ( ) ?. [ 2 ] ?. env ) . toMatchObject ( {
17961804 OPENCLAW_PROFILE : "personal" ,
1797- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/personal-profile" ,
1805+ OPENCLAW_STATE_DIR : personalState ,
17981806 OPENCLAW_GATEWAY_PORT : "19111" ,
17991807 } ) ;
18001808 } ) ;
@@ -1810,7 +1818,7 @@ describe("update-cli", () => {
18101818 after : { sha : "new-managed-sha" , version : "2026.4.27" } ,
18111819 } ) ,
18121820 ) ;
1813- const managedState = "/tmp/openclaw-update-tests/ fallback-managed";
1821+ const managedState = path . join ( fixtureRoot , " fallback-managed") ;
18141822 serviceReadCommand . mockResolvedValue ( {
18151823 programArguments : [ "node" , path . join ( process . cwd ( ) , "dist" , "index.js" ) , "gateway" , "run" ] ,
18161824 environment : {
@@ -1835,7 +1843,7 @@ describe("update-cli", () => {
18351843 await withEnvAsync (
18361844 {
18371845 OPENCLAW_PROFILE : "personal" ,
1838- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/ fallback-personal",
1846+ OPENCLAW_STATE_DIR : path . join ( fixtureRoot , " fallback-personal") ,
18391847 OPENCLAW_GATEWAY_PORT : "19111" ,
18401848 } ,
18411849 async ( ) => {
@@ -1868,7 +1876,7 @@ describe("update-cli", () => {
18681876 candidate === path . join ( process . cwd ( ) , "package.json" ) ||
18691877 candidate === path . join ( process . cwd ( ) , "openclaw.mjs" ) ,
18701878 ) ;
1871- const managedState = "/tmp/openclaw-update-tests/ restart-doctor-managed";
1879+ const managedState = path . join ( fixtureRoot , " restart-doctor-managed") ;
18721880 serviceReadCommand . mockResolvedValue ( {
18731881 programArguments : [ "node" , path . join ( process . cwd ( ) , "dist" , "index.js" ) , "gateway" , "run" ] ,
18741882 environment : {
@@ -1890,7 +1898,7 @@ describe("update-cli", () => {
18901898 await withEnvAsync (
18911899 {
18921900 OPENCLAW_PROFILE : "personal" ,
1893- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/ restart-doctor-personal",
1901+ OPENCLAW_STATE_DIR : path . join ( fixtureRoot , " restart-doctor-personal") ,
18941902 OPENCLAW_GATEWAY_PORT : "19111" ,
18951903 } ,
18961904 async ( ) => {
0 commit comments