@@ -37,6 +37,57 @@ describe.runIf(
3737 }
3838 } ) ;
3939
40+ it . each ( [ "owned" , "outside" , "symlink" , "nonempty" , "nested" ] ) (
41+ "validates a supplied %s staging directory" ,
42+ ( mode ) => {
43+ const fixture = createFixture ( ) ;
44+ try {
45+ const stage = NodePath . join (
46+ fixture . dir ,
47+ mode === "outside"
48+ ? "external-stage"
49+ : mode === "nested"
50+ ? ".t3-update.external/nested"
51+ : ".t3-update.external" ,
52+ ) ;
53+ const unrelated = NodePath . join ( fixture . dir , "unrelated" ) ;
54+ NodeFS . mkdirSync ( unrelated ) ;
55+ NodeFS . writeFileSync ( NodePath . join ( unrelated , "keep" ) , "untouched" ) ;
56+ if ( mode === "symlink" ) NodeFS . symlinkSync ( unrelated , stage ) ;
57+ else NodeFS . mkdirSync ( stage , { recursive : true } ) ;
58+ if ( mode === "nonempty" ) NodeFS . writeFileSync ( NodePath . join ( stage , "keep" ) , "untouched" ) ;
59+ fixture . env . T3CODE_DESKTOP_UPDATE_STAGE = stage ;
60+ const result = fixture . attempt ( ) ;
61+ NodeAssert . equal ( typeof result . status , "number" , result . error ?. message ) ;
62+ if ( mode === "owned" ) {
63+ NodeAssert . equal ( result . status , 0 , result . stderr ) ;
64+ NodeAssert . deepEqual ( snapshot ( fixture . app ) , fixture . expected ) ;
65+ NodeAssert . equal (
66+ NodeFS . readFileSync ( NodePath . join ( stage , "installed-app" ) , "utf8" ) . trim ( ) ,
67+ fixture . app ,
68+ ) ;
69+ } else {
70+ NodeAssert . notEqual ( result . status , 0 ) ;
71+ NodeAssert . equal (
72+ NodeFS . readFileSync ( NodePath . join ( fixture . app , ".version" ) , "utf8" ) ,
73+ "1.0.0" ,
74+ ) ;
75+ if ( mode === "nonempty" )
76+ NodeAssert . equal (
77+ NodeFS . readFileSync ( NodePath . join ( stage , "keep" ) , "utf8" ) ,
78+ "untouched" ,
79+ ) ;
80+ }
81+ NodeAssert . equal (
82+ NodeFS . readFileSync ( NodePath . join ( unrelated , "keep" ) , "utf8" ) ,
83+ "untouched" ,
84+ ) ;
85+ } finally {
86+ fixture . clean ( ) ;
87+ }
88+ } ,
89+ ) ;
90+
4091 it ( "rejects invalid parent arguments before signalling readiness" , ( ) => {
4192 for ( const parent of [ "0" , "1" , "-1" , "oops" ] ) {
4293 const result = run ( "/bin/sh" , [
0 commit comments