@@ -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
@@ -1481,8 +1486,9 @@ describe("update-cli", () => {
14811486 setStdoutTty ( false ) ;
14821487 } ) ;
14831488
1484- afterAll ( ( ) => {
1489+ afterAll ( async ( ) => {
14851490 serviceEnvSnapshot . restore ( ) ;
1491+ await fs . rm ( fixtureRoot , { recursive : true , force : true } ) ;
14861492 } ) ;
14871493
14881494 afterEach ( async ( ) => {
@@ -1662,7 +1668,8 @@ describe("update-cli", () => {
16621668 candidate === path . join ( root , "package.json" ) ||
16631669 entrypoints . includes ( candidate ) ,
16641670 ) ;
1665- const managedState = "/tmp/openclaw-update-tests/managed-profile" ;
1671+ const managedState = path . join ( fixtureRoot , "managed-profile" ) ;
1672+ const personalState = path . join ( fixtureRoot , "personal-profile" ) ;
16661673 const managedConfig = {
16671674 ...baseConfig ,
16681675 update : { channel : "beta" as const } ,
@@ -1717,8 +1724,8 @@ describe("update-cli", () => {
17171724 await withEnvAsync (
17181725 {
17191726 OPENCLAW_PROFILE : "personal" ,
1720- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/personal-profile" ,
1721- OPENCLAW_CONFIG_PATH : "/tmp/ openclaw-update-tests/personal-profile/openclaw .json",
1727+ OPENCLAW_STATE_DIR : personalState ,
1728+ OPENCLAW_CONFIG_PATH : path . join ( personalState , " openclaw.json") ,
17221729 OPENCLAW_GATEWAY_PORT : "19111" ,
17231730 } ,
17241731 async ( ) => {
@@ -1740,6 +1747,7 @@ describe("update-cli", () => {
17401747 } ) ;
17411748
17421749 it ( "keeps foreign-service updates in the caller profile" , async ( ) => {
1750+ const personalState = path . join ( fixtureRoot , "personal-profile" ) ;
17431751 const { root, entrypoints } = setupUpdatedRootRefresh ( ) ;
17441752 const foreignRoot = await createTrackedTempDir ( "openclaw-update-foreign-profile-" ) ;
17451753 const foreignEntrypoint = path . join ( foreignRoot , "dist" , "index.js" ) ;
@@ -1762,7 +1770,7 @@ describe("update-cli", () => {
17621770 programArguments : [ "node" , foreignEntrypoint , "gateway" , "run" ] ,
17631771 environment : {
17641772 OPENCLAW_PROFILE : "foreign" ,
1765- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/ foreign-profile",
1773+ OPENCLAW_STATE_DIR : path . join ( fixtureRoot , " foreign-profile") ,
17661774 OPENCLAW_GATEWAY_PORT : "19333" ,
17671775 } ,
17681776 } ) ;
@@ -1776,7 +1784,7 @@ describe("update-cli", () => {
17761784 await withEnvAsync (
17771785 {
17781786 OPENCLAW_PROFILE : "personal" ,
1779- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/personal-profile" ,
1787+ OPENCLAW_STATE_DIR : personalState ,
17801788 OPENCLAW_GATEWAY_PORT : "19111" ,
17811789 } ,
17821790 async ( ) => {
@@ -1788,7 +1796,7 @@ describe("update-cli", () => {
17881796 expect ( serviceEnabled ) . not . toHaveBeenCalled ( ) ;
17891797 expect ( spawnCall ( ) ?. [ 2 ] ?. env ) . toMatchObject ( {
17901798 OPENCLAW_PROFILE : "personal" ,
1791- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/personal-profile" ,
1799+ OPENCLAW_STATE_DIR : personalState ,
17921800 OPENCLAW_GATEWAY_PORT : "19111" ,
17931801 } ) ;
17941802 } ) ;
@@ -1804,7 +1812,7 @@ describe("update-cli", () => {
18041812 after : { sha : "new-managed-sha" , version : "2026.4.27" } ,
18051813 } ) ,
18061814 ) ;
1807- const managedState = "/tmp/openclaw-update-tests/ fallback-managed";
1815+ const managedState = path . join ( fixtureRoot , " fallback-managed") ;
18081816 serviceReadCommand . mockResolvedValue ( {
18091817 programArguments : [ "node" , path . join ( process . cwd ( ) , "dist" , "index.js" ) , "gateway" , "run" ] ,
18101818 environment : {
@@ -1829,7 +1837,7 @@ describe("update-cli", () => {
18291837 await withEnvAsync (
18301838 {
18311839 OPENCLAW_PROFILE : "personal" ,
1832- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/ fallback-personal",
1840+ OPENCLAW_STATE_DIR : path . join ( fixtureRoot , " fallback-personal") ,
18331841 OPENCLAW_GATEWAY_PORT : "19111" ,
18341842 } ,
18351843 async ( ) => {
@@ -1862,7 +1870,7 @@ describe("update-cli", () => {
18621870 candidate === path . join ( process . cwd ( ) , "package.json" ) ||
18631871 candidate === path . join ( process . cwd ( ) , "openclaw.mjs" ) ,
18641872 ) ;
1865- const managedState = "/tmp/openclaw-update-tests/ restart-doctor-managed";
1873+ const managedState = path . join ( fixtureRoot , " restart-doctor-managed") ;
18661874 serviceReadCommand . mockResolvedValue ( {
18671875 programArguments : [ "node" , path . join ( process . cwd ( ) , "dist" , "index.js" ) , "gateway" , "run" ] ,
18681876 environment : {
@@ -1884,7 +1892,7 @@ describe("update-cli", () => {
18841892 await withEnvAsync (
18851893 {
18861894 OPENCLAW_PROFILE : "personal" ,
1887- OPENCLAW_STATE_DIR : "/tmp/openclaw-update-tests/ restart-doctor-personal",
1895+ OPENCLAW_STATE_DIR : path . join ( fixtureRoot , " restart-doctor-personal") ,
18881896 OPENCLAW_GATEWAY_PORT : "19111" ,
18891897 } ,
18901898 async ( ) => {
0 commit comments