@@ -185,7 +185,7 @@ public class BuildScriptTests
185185 // Records the arguments passed to StartCallback.
186186 IList < string > StartCallbackIn = new List < string > ( ) ;
187187
188- void StartCallback ( string s )
188+ void StartCallback ( string s , bool silent )
189189 {
190190 StartCallbackIn . Add ( s ) ;
191191 }
@@ -194,7 +194,7 @@ void StartCallback(string s)
194194 IList < string > EndCallbackIn = new List < string > ( ) ;
195195 IList < int > EndCallbackReturn = new List < int > ( ) ;
196196
197- void EndCallback ( int ret , string s )
197+ void EndCallback ( int ret , string s , bool silent )
198198 {
199199 EndCallbackReturn . Add ( ret ) ;
200200 EndCallbackIn . Add ( s ) ;
@@ -203,7 +203,7 @@ void EndCallback(int ret, string s)
203203 [ Fact ]
204204 public void TestBuildCommand ( )
205205 {
206- var cmd = BuildScript . Create ( "abc" , "def ghi" , null , null ) ;
206+ var cmd = BuildScript . Create ( "abc" , "def ghi" , false , null , null ) ;
207207
208208 Actions . RunProcess [ "abc def ghi" ] = 1 ;
209209 cmd . Run ( Actions , StartCallback , EndCallback ) ;
@@ -216,7 +216,7 @@ public void TestBuildCommand()
216216 [ Fact ]
217217 public void TestAnd1 ( )
218218 {
219- var cmd = BuildScript . Create ( "abc" , "def ghi" , null , null ) & BuildScript . Create ( "odasa" , null , null , null ) ;
219+ var cmd = BuildScript . Create ( "abc" , "def ghi" , false , null , null ) & BuildScript . Create ( "odasa" , null , false , null , null ) ;
220220
221221 Actions . RunProcess [ "abc def ghi" ] = 1 ;
222222 cmd . Run ( Actions , StartCallback , EndCallback ) ;
@@ -230,7 +230,7 @@ public void TestAnd1()
230230 [ Fact ]
231231 public void TestAnd2 ( )
232232 {
233- var cmd = BuildScript . Create ( "odasa" , null , null , null ) & BuildScript . Create ( "abc" , "def ghi" , null , null ) ;
233+ var cmd = BuildScript . Create ( "odasa" , null , false , null , null ) & BuildScript . Create ( "abc" , "def ghi" , false , null , null ) ;
234234
235235 Actions . RunProcess [ "abc def ghi" ] = 1 ;
236236 Actions . RunProcess [ "odasa " ] = 0 ;
@@ -250,7 +250,7 @@ public void TestAnd2()
250250 [ Fact ]
251251 public void TestOr1 ( )
252252 {
253- var cmd = BuildScript . Create ( "odasa" , null , null , null ) | BuildScript . Create ( "abc" , "def ghi" , null , null ) ;
253+ var cmd = BuildScript . Create ( "odasa" , null , false , null , null ) | BuildScript . Create ( "abc" , "def ghi" , false , null , null ) ;
254254
255255 Actions . RunProcess [ "abc def ghi" ] = 1 ;
256256 Actions . RunProcess [ "odasa " ] = 0 ;
@@ -266,7 +266,7 @@ public void TestOr1()
266266 [ Fact ]
267267 public void TestOr2 ( )
268268 {
269- var cmd = BuildScript . Create ( "abc" , "def ghi" , null , null ) | BuildScript . Create ( "odasa" , null , null , null ) ;
269+ var cmd = BuildScript . Create ( "abc" , "def ghi" , false , null , null ) | BuildScript . Create ( "odasa" , null , false , null , null ) ;
270270
271271 Actions . RunProcess [ "abc def ghi" ] = 1 ;
272272 Actions . RunProcess [ "odasa " ] = 0 ;
@@ -375,7 +375,7 @@ public void TestDefaultCSharpAutoBuilder()
375375 Actions . RunProcess [ "cmd.exe /C dotnet --info" ] = 0 ;
376376 Actions . RunProcess [ "cmd.exe /C dotnet clean test.csproj" ] = 0 ;
377377 Actions . RunProcess [ "cmd.exe /C dotnet restore test.csproj" ] = 0 ;
378- Actions . RunProcess [ @"cmd.exe /C C:\odasa\tools\odasa index --auto dotnet build --no-incremental /p:UseSharedCompilation=false test.csproj" ] = 0 ;
378+ Actions . RunProcess [ @"cmd.exe /C C:\odasa\tools\odasa index --auto dotnet build --no-incremental test.csproj" ] = 0 ;
379379 Actions . RunProcess [ @"cmd.exe /C C:\codeql\tools\java\bin\java -jar C:\codeql\csharp\tools\extractor-asp.jar ." ] = 0 ;
380380 Actions . RunProcess [ @"cmd.exe /C C:\odasa\tools\odasa index --xml --extensions config csproj props xml" ] = 0 ;
381381 Actions . FileExists [ "csharp.log" ] = true ;
@@ -401,6 +401,9 @@ public void TestDefaultCSharpAutoBuilder()
401401 [ Fact ]
402402 public void TestLinuxCSharpAutoBuilder ( )
403403 {
404+ Actions . RunProcess [ "dotnet --list-runtimes" ] = 0 ;
405+ Actions . RunProcessOut [ "dotnet --list-runtimes" ] = @"Microsoft.AspNetCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
406+ Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]" ;
404407 Actions . RunProcess [ "dotnet --info" ] = 0 ;
405408 Actions . RunProcess [ "dotnet clean test.csproj" ] = 0 ;
406409 Actions . RunProcess [ "dotnet restore test.csproj" ] = 0 ;
@@ -424,7 +427,7 @@ public void TestLinuxCSharpAutoBuilder()
424427 Actions . LoadXml [ "test.csproj" ] = xml ;
425428
426429 var autobuilder = CreateAutoBuilder ( "csharp" , false ) ;
427- TestAutobuilderScript ( autobuilder , 0 , 6 ) ;
430+ TestAutobuilderScript ( autobuilder , 0 , 7 ) ;
428431 }
429432
430433 [ Fact ]
@@ -598,6 +601,8 @@ void TestAutobuilderScript(Autobuilder autobuilder, int expectedOutput, int comm
598601 [ Fact ]
599602 public void TestLinuxBuildCommand ( )
600603 {
604+ Actions . RunProcess [ "dotnet --list-runtimes" ] = 1 ;
605+ Actions . RunProcessOut [ "dotnet --list-runtimes" ] = "" ;
601606 Actions . RunProcess [ @"C:\odasa/tools/odasa index --auto ""./build.sh --skip-tests""" ] = 0 ;
602607 Actions . RunProcess [ @"C:\codeql\tools\java/bin/java -jar C:\codeql\csharp/tools/extractor-asp.jar ." ] = 0 ;
603608 Actions . RunProcess [ @"C:\odasa/tools/odasa index --xml --extensions config csproj props xml" ] = 0 ;
@@ -610,7 +615,7 @@ public void TestLinuxBuildCommand()
610615 SkipVsWhere ( ) ;
611616
612617 var autobuilder = CreateAutoBuilder ( "csharp" , false , buildCommand : "./build.sh --skip-tests" ) ;
613- TestAutobuilderScript ( autobuilder , 0 , 3 ) ;
618+ TestAutobuilderScript ( autobuilder , 0 , 4 ) ;
614619 }
615620
616621 [ Fact ]
@@ -621,14 +626,16 @@ public void TestLinuxBuildSh()
621626 Actions . GetEnvironmentVariable [ "CODEQL_EXTRACTOR_CSHARP_TRAP_DIR" ] = "" ;
622627 Actions . GetEnvironmentVariable [ "CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR" ] = "" ;
623628 Actions . RunProcess [ "/bin/chmod u+x build/build.sh" ] = 0 ;
629+ Actions . RunProcess [ "dotnet --list-runtimes" ] = 1 ;
630+ Actions . RunProcessOut [ "dotnet --list-runtimes" ] = "" ;
624631 Actions . RunProcess [ @"C:\odasa/tools/odasa index --auto build/build.sh" ] = 0 ;
625632 Actions . RunProcessWorkingDirectory [ @"C:\odasa/tools/odasa index --auto build/build.sh" ] = "build" ;
626633 Actions . RunProcess [ @"C:\codeql\tools\java/bin/java -jar C:\codeql\csharp/tools/extractor-asp.jar ." ] = 0 ;
627634 Actions . RunProcess [ @"C:\odasa/tools/odasa index --xml --extensions config csproj props xml" ] = 0 ;
628635 Actions . FileExists [ "csharp.log" ] = true ;
629636
630637 var autobuilder = CreateAutoBuilder ( "csharp" , false ) ;
631- TestAutobuilderScript ( autobuilder , 0 , 4 ) ;
638+ TestAutobuilderScript ( autobuilder , 0 , 5 ) ;
632639 }
633640
634641 [ Fact ]
@@ -640,12 +647,14 @@ public void TestLinuxBuildShCSharpLogMissing()
640647 Actions . GetEnvironmentVariable [ "CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR" ] = "" ;
641648
642649 Actions . RunProcess [ "/bin/chmod u+x build.sh" ] = 0 ;
650+ Actions . RunProcess [ "dotnet --list-runtimes" ] = 1 ;
651+ Actions . RunProcessOut [ "dotnet --list-runtimes" ] = "" ;
643652 Actions . RunProcess [ @"C:\odasa/tools/odasa index --auto build.sh" ] = 0 ;
644653 Actions . RunProcessWorkingDirectory [ @"C:\odasa/tools/odasa index --auto build.sh" ] = "" ;
645654 Actions . FileExists [ "csharp.log" ] = false ;
646655
647656 var autobuilder = CreateAutoBuilder ( "csharp" , false ) ;
648- TestAutobuilderScript ( autobuilder , 1 , 2 ) ;
657+ TestAutobuilderScript ( autobuilder , 1 , 3 ) ;
649658 }
650659
651660 [ Fact ]
@@ -657,12 +666,14 @@ public void TestLinuxBuildShFailed()
657666 Actions . GetEnvironmentVariable [ "CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR" ] = "" ;
658667
659668 Actions . RunProcess [ "/bin/chmod u+x build.sh" ] = 0 ;
669+ Actions . RunProcess [ "dotnet --list-runtimes" ] = 1 ;
670+ Actions . RunProcessOut [ "dotnet --list-runtimes" ] = "" ;
660671 Actions . RunProcess [ @"C:\odasa/tools/odasa index --auto build.sh" ] = 5 ;
661672 Actions . RunProcessWorkingDirectory [ @"C:\odasa/tools/odasa index --auto build.sh" ] = "" ;
662673 Actions . FileExists [ "csharp.log" ] = true ;
663674
664675 var autobuilder = CreateAutoBuilder ( "csharp" , false ) ;
665- TestAutobuilderScript ( autobuilder , 1 , 2 ) ;
676+ TestAutobuilderScript ( autobuilder , 1 , 3 ) ;
666677 }
667678
668679 [ Fact ]
@@ -748,7 +759,7 @@ public void TestWindowCSharpMsBuild()
748759 TestAutobuilderScript ( autobuilder , 0 , 6 ) ;
749760 }
750761
751- [ Fact ]
762+ [ Fact ]
752763 public void TestWindowCSharpMsBuildMultipleSolutions ( )
753764 {
754765 Actions . RunProcess [ @"cmd.exe /C C:\odasa\tools\csharp\nuget\nuget.exe restore test1.csproj" ] = 0 ;
@@ -871,6 +882,9 @@ public void TestSkipNugetBuildless()
871882 [ Fact ]
872883 public void TestSkipNugetDotnet ( )
873884 {
885+ Actions . RunProcess [ "dotnet --list-runtimes" ] = 0 ;
886+ Actions . RunProcessOut [ "dotnet --list-runtimes" ] = @"Microsoft.AspNetCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
887+ Microsoft.NETCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]" ;
874888 Actions . RunProcess [ "dotnet --info" ] = 0 ;
875889 Actions . RunProcess [ "dotnet clean test.csproj" ] = 0 ;
876890 Actions . RunProcess [ "dotnet restore test.csproj" ] = 0 ;
@@ -894,7 +908,7 @@ public void TestSkipNugetDotnet()
894908 Actions . LoadXml [ "test.csproj" ] = xml ;
895909
896910 var autobuilder = CreateAutoBuilder ( "csharp" , false , dotnetArguments : "--no-restore" ) ; // nugetRestore=false does not work for now.
897- TestAutobuilderScript ( autobuilder , 0 , 6 ) ;
911+ TestAutobuilderScript ( autobuilder , 0 , 7 ) ;
898912 }
899913
900914 [ Fact ]
@@ -906,10 +920,13 @@ public void TestDotnetVersionNotInstalled()
906920 Actions . RunProcess [ @"chmod u+x dotnet-install.sh" ] = 0 ;
907921 Actions . RunProcess [ @"./dotnet-install.sh --channel release --version 2.1.3 --install-dir C:\Project/.dotnet" ] = 0 ;
908922 Actions . RunProcess [ @"rm dotnet-install.sh" ] = 0 ;
923+ Actions . RunProcess [ @"C:\Project/.dotnet/dotnet --list-runtimes" ] = 0 ;
924+ Actions . RunProcessOut [ @"C:\Project/.dotnet/dotnet --list-runtimes" ] = @"Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
925+ Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]" ;
909926 Actions . RunProcess [ @"C:\Project/.dotnet/dotnet --info" ] = 0 ;
910927 Actions . RunProcess [ @"C:\Project/.dotnet/dotnet clean test.csproj" ] = 0 ;
911928 Actions . RunProcess [ @"C:\Project/.dotnet/dotnet restore test.csproj" ] = 0 ;
912- Actions . RunProcess [ @"C:\odasa/tools/odasa index --auto C:\Project/.dotnet/dotnet build --no-incremental /p:UseSharedCompilation=false test.csproj" ] = 0 ;
929+ Actions . RunProcess [ @"C:\odasa/tools/odasa index --auto C:\Project/.dotnet/dotnet build --no-incremental test.csproj" ] = 0 ;
913930 Actions . RunProcess [ @"C:\codeql\tools\java/bin/java -jar C:\codeql\csharp/tools/extractor-asp.jar ." ] = 0 ;
914931 Actions . RunProcess [ @"C:\odasa/tools/odasa index --xml --extensions config csproj props xml" ] = 0 ;
915932 Actions . FileExists [ "csharp.log" ] = true ;
@@ -930,18 +947,24 @@ public void TestDotnetVersionNotInstalled()
930947 Actions . LoadXml [ "test.csproj" ] = xml ;
931948
932949 var autobuilder = CreateAutoBuilder ( "csharp" , false , dotnetVersion : "2.1.3" ) ;
933- TestAutobuilderScript ( autobuilder , 0 , 11 ) ;
950+ TestAutobuilderScript ( autobuilder , 0 , 12 ) ;
934951 }
935952
936953 [ Fact ]
937954 public void TestDotnetVersionAlreadyInstalled ( )
938955 {
939956 Actions . RunProcess [ "dotnet --list-sdks" ] = 0 ;
940- Actions . RunProcessOut [ "dotnet --list-sdks" ] = "2.1.3 [C:\\ Program Files\\ dotnet\\ sdks]\n 2.1.4 [C:\\ Program Files\\ dotnet\\ sdks]" ;
957+ Actions . RunProcessOut [ "dotnet --list-sdks" ] = @"2.1.3 [C:\Program Files\dotnet\sdks]
958+ 2.1.4 [C:\Program Files\dotnet\sdks]" ;
941959 Actions . RunProcess [ @"curl -L -sO https://dot.net/v1/dotnet-install.sh" ] = 0 ;
942960 Actions . RunProcess [ @"chmod u+x dotnet-install.sh" ] = 0 ;
943961 Actions . RunProcess [ @"./dotnet-install.sh --channel release --version 2.1.3 --install-dir C:\Project/.dotnet" ] = 0 ;
944962 Actions . RunProcess [ @"rm dotnet-install.sh" ] = 0 ;
963+ Actions . RunProcess [ @"C:\Project/.dotnet/dotnet --list-runtimes" ] = 0 ;
964+ Actions . RunProcessOut [ @"C:\Project/.dotnet/dotnet --list-runtimes" ] = @"Microsoft.AspNetCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
965+ Microsoft.AspNetCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
966+ Microsoft.NETCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
967+ Microsoft.NETCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]" ;
945968 Actions . RunProcess [ @"C:\Project/.dotnet/dotnet --info" ] = 0 ;
946969 Actions . RunProcess [ @"C:\Project/.dotnet/dotnet clean test.csproj" ] = 0 ;
947970 Actions . RunProcess [ @"C:\Project/.dotnet/dotnet restore test.csproj" ] = 0 ;
@@ -966,7 +989,7 @@ public void TestDotnetVersionAlreadyInstalled()
966989 Actions . LoadXml [ "test.csproj" ] = xml ;
967990
968991 var autobuilder = CreateAutoBuilder ( "csharp" , false , dotnetVersion : "2.1.3" ) ;
969- TestAutobuilderScript ( autobuilder , 0 , 11 ) ;
992+ TestAutobuilderScript ( autobuilder , 0 , 12 ) ;
970993 }
971994
972995 [ Fact ]
@@ -979,7 +1002,7 @@ public void TestDotnetVersionWindows()
9791002 Actions . RunProcess [ @"cmd.exe /C C:\Project\.dotnet\dotnet --info" ] = 0 ;
9801003 Actions . RunProcess [ @"cmd.exe /C C:\Project\.dotnet\dotnet clean test.csproj" ] = 0 ;
9811004 Actions . RunProcess [ @"cmd.exe /C C:\Project\.dotnet\dotnet restore test.csproj" ] = 0 ;
982- Actions . RunProcess [ @"cmd.exe /C C:\odasa\tools\odasa index --auto C:\Project\.dotnet\dotnet build --no-incremental /p:UseSharedCompilation=false test.csproj" ] = 0 ;
1005+ Actions . RunProcess [ @"cmd.exe /C C:\odasa\tools\odasa index --auto C:\Project\.dotnet\dotnet build --no-incremental test.csproj" ] = 0 ;
9831006 Actions . RunProcess [ @"cmd.exe /C C:\codeql\tools\java\bin\java -jar C:\codeql\csharp\tools\extractor-asp.jar ." ] = 0 ;
9841007 Actions . RunProcess [ @"cmd.exe /C C:\odasa\tools\odasa index --xml --extensions config csproj props xml" ] = 0 ;
9851008 Actions . FileExists [ "csharp.log" ] = true ;
0 commit comments