@@ -71,31 +71,47 @@ public void UseNewNodeForNewNodeHandler(string nodeVersion)
7171 {
7272 ResetNodeKnobs ( ) ;
7373
74- // Use a unique test name per data row to avoid sharing the same trace file across parallel runs
75- using ( TestHostContext thc = CreateTestHostContext ( $ " { nameof ( UseNewNodeForNewNodeHandler ) } _ { nodeVersion } " ) )
74+ // For node24, set the required knob
75+ if ( nodeVersion == "node24" )
7676 {
77- thc . SetSingleton ( new WorkerCommandManager ( ) as IWorkerCommandManager ) ;
78- thc . SetSingleton ( new ExtensionManager ( ) as IExtensionManager ) ;
79-
80- NodeHandler nodeHandler = new NodeHandler ( nodeHandlerHalper . Object ) ;
77+ Environment . SetEnvironmentVariable ( "AGENT_USE_NODE24" , "true" ) ;
78+ }
8179
82- nodeHandler . Initialize ( thc ) ;
83- nodeHandler . ExecutionContext = CreateTestExecutionContext ( thc ) ;
84- nodeHandler . Data = nodeVersion switch
80+ try
81+ {
82+ // Use a unique test name per data row to avoid sharing the same trace file across parallel runs
83+ using ( TestHostContext thc = CreateTestHostContext ( $ "{ nameof ( UseNewNodeForNewNodeHandler ) } _{ nodeVersion } ") )
8584 {
86- "node10" => new Node10HandlerData ( ) ,
87- "node16" => new Node16HandlerData ( ) ,
88- "node20_1" => new Node20_1HandlerData ( ) ,
89- "node24" => new Node24HandlerData ( ) ,
90- _ => throw new Exception ( "Invalid node version" ) ,
91- } ;
85+ thc . SetSingleton ( new WorkerCommandManager ( ) as IWorkerCommandManager ) ;
86+ thc . SetSingleton ( new ExtensionManager ( ) as IExtensionManager ) ;
9287
93- string actualLocation = nodeHandler . GetNodeLocation ( node20ResultsInGlibCError : false , node24ResultsInGlibCError : false , inContainer : false ) ;
94- string expectedLocation = Path . Combine ( thc . GetDirectory ( WellKnownDirectory . Externals ) ,
95- nodeVersion ,
96- "bin" ,
97- $ "node{ IOUtil . ExeExtension } ") ;
98- Assert . Equal ( expectedLocation , actualLocation ) ;
88+ NodeHandler nodeHandler = new NodeHandler ( nodeHandlerHalper . Object ) ;
89+
90+ nodeHandler . Initialize ( thc ) ;
91+ nodeHandler . ExecutionContext = CreateTestExecutionContext ( thc ) ;
92+ nodeHandler . Data = nodeVersion switch
93+ {
94+ "node10" => new Node10HandlerData ( ) ,
95+ "node16" => new Node16HandlerData ( ) ,
96+ "node20_1" => new Node20_1HandlerData ( ) ,
97+ "node24" => new Node24HandlerData ( ) ,
98+ _ => throw new Exception ( "Invalid node version" ) ,
99+ } ;
100+
101+ string actualLocation = nodeHandler . GetNodeLocation ( node20ResultsInGlibCError : false , node24ResultsInGlibCError : false , inContainer : false ) ;
102+ string expectedLocation = Path . Combine ( thc . GetDirectory ( WellKnownDirectory . Externals ) ,
103+ nodeVersion ,
104+ "bin" ,
105+ $ "node{ IOUtil . ExeExtension } ") ;
106+ Assert . Equal ( expectedLocation , actualLocation ) ;
107+ }
108+ }
109+ finally
110+ {
111+ if ( nodeVersion == "node24" )
112+ {
113+ Environment . SetEnvironmentVariable ( "AGENT_USE_NODE24" , null ) ;
114+ }
99115 }
100116 }
101117
@@ -477,4 +493,4 @@ private void ResetNodeKnobs()
477493 Environment . SetEnvironmentVariable ( "AGENT_USE_NODE24_IN_UNSUPPORTED_SYSTEM" , null ) ;
478494 }
479495 }
480- }
496+ }
0 commit comments