@@ -615,6 +615,58 @@ public void LanguageWorker_FormatWorkerPath_DefualtRuntimeVersion_WorkerRuntimeM
615
615
Assert . Equal ( "3.7" , workerDescription . DefaultRuntimeVersion ) ;
616
616
}
617
617
618
+ public static IEnumerable < object [ ] > RpcWorkerDescriptionArgumentsWithPlaceholder ( )
619
+ {
620
+ yield return new object [ ] { "D:/Code/Host/workers/java" , new List < string > { RpcWorkerConstants . WorkerDirectoryPath } } ;
621
+ yield return new object [ ] { "/java" , new List < string > { string . Concat ( "/path/version/" , RpcWorkerConstants . WorkerDirectoryPath ) } } ;
622
+ yield return new object [ ] { "/" , new List < string > { string . Concat ( "version/" , RpcWorkerConstants . WorkerDirectoryPath ) } } ;
623
+ }
624
+
625
+ [ Theory ]
626
+ [ MemberData ( nameof ( RpcWorkerDescriptionArgumentsWithPlaceholder ) ) ]
627
+ public void LanguageWorker_FormatArguments_ReplacePlaceholder ( string workerDirectory , List < string > arguments )
628
+ {
629
+ RpcWorkerDescription workerDescription = new RpcWorkerDescription ( )
630
+ {
631
+ Arguments = arguments ,
632
+ DefaultExecutablePath = "python" ,
633
+ WorkerDirectory = workerDirectory ,
634
+ Language = "python"
635
+ } ;
636
+ workerDescription . FormatArgumentsIfNeeded ( new TestLogger ( testLanguage ) ) ;
637
+
638
+ for ( int i = 0 ; i < arguments . Count ; i ++ )
639
+ {
640
+ Assert . Contains ( workerDirectory , workerDescription . Arguments [ i ] ) ;
641
+ }
642
+ }
643
+
644
+ public static IEnumerable < object [ ] > RpcWorkerDescriptionArgumentsWithoutPlaceholder ( )
645
+ {
646
+ yield return new object [ ] { "D:/Code/Host/workers/java" , new List < string > { } } ;
647
+ yield return new object [ ] { "D:/Code/Host/workers/" , new List < string > { string . Empty , null } } ;
648
+ yield return new object [ ] { "/worker/path" , new List < string > { string . Empty , null , "/path/version/" } } ;
649
+ }
650
+
651
+ [ Theory ]
652
+ [ MemberData ( nameof ( RpcWorkerDescriptionArgumentsWithoutPlaceholder ) ) ]
653
+ public void LanguageWorker_FormatArguments_DoNotReplacePlaceholder ( string workerDirectory , List < string > arguments )
654
+ {
655
+ RpcWorkerDescription workerDescription = new RpcWorkerDescription ( )
656
+ {
657
+ Arguments = arguments ,
658
+ DefaultExecutablePath = "python" ,
659
+ WorkerDirectory = workerDirectory ,
660
+ Language = "python"
661
+ } ;
662
+ workerDescription . FormatArgumentsIfNeeded ( new TestLogger ( testLanguage ) ) ;
663
+
664
+ for ( int i = 0 ; i < arguments . Count ; i ++ )
665
+ {
666
+ Assert . DoesNotContain ( workerDirectory , workerDescription . Arguments [ i ] ) ;
667
+ }
668
+ }
669
+
618
670
private IEnumerable < RpcWorkerConfig > TestReadWorkerProviderFromConfig ( IEnumerable < TestRpcWorkerConfig > configs , ILogger testLogger , TestMetricsLogger testMetricsLogger , string language = null , Dictionary < string , string > keyValuePairs = null , bool appSvcEnv = false )
619
671
{
620
672
Mock < IEnvironment > mockEnvironment = new Mock < IEnvironment > ( ) ;
0 commit comments