@@ -26,21 +26,25 @@ Param(
2626  [Switch ] $Help  =  $false 
2727)
2828
29- .  $PSScriptRoot \common.lib.ps1
30- 
3129# 
3230#  Script Preferences
3331# 
3432$ErrorActionPreference  =  " Stop" 
3533
34+ $CurrentScriptDir  =  (Get-Item  (Split-Path  $MyInvocation.MyCommand.Path  ))
35+ 
3636# 
3737#  Variables
3838# 
39+ $env: TF_ROOT_DIR  =  $CurrentScriptDir.Parent.FullName  
40+ $env: TF_TOOLS_DIR  =  Join-Path  $env: TF_ROOT_DIR  " tools" 
41+ $env: DOTNET_CLI_VERSION  =  " 6.0.100-alpha.1.21067.8" 
3942$env: TF_TESTS_OUTDIR_PATTERN  =  " *.Tests" 
4043$env: TF_UNITTEST_FILES_PATTERN  =  " *.UnitTests*.dll" 
4144$env: TF_COMPONENTTEST_FILES_PATTERN  =  " *.ComponentTests*.dll" 
4245$env: TF_E2ETEST_FILES_PATTERN  =  " *.E2ETests*.dll" 
4346$env: TF_NetCoreContainers  = @ (" MSTestAdapter.PlatformServices.NetCore.UnitTests.dll"  )
47+ 
4448# 
4549#  Test configuration
4650# 
@@ -49,7 +53,9 @@ $TFT_Configuration = $Configuration
4953$TFT_Pattern  =  $Pattern 
5054$TFT_Parallel  =  $Parallel 
5155$TFT_All  =  $All 
52- $TestFramework  =  " .NETCoreApp,Version=v2.1" 
56+ $TestFramework  =  " .NETCoreApp2.1" 
57+ 
58+ .  $PSScriptRoot \common.lib.ps1
5359
5460# 
5561#  Prints help text for the switches this script supports.
@@ -75,52 +81,54 @@ function Print-Help {
7581
7682function  Invoke-Test 
7783{
84+     &  dotnet -- info
85+ 
7886    $timer  =  Start-Timer 
7987
8088    Write-Log  " Run-Test: Started." 
81- 	 
89+      
8290    Write-Log  "     Computing Test Containers." 
8391    #  Get all the test project folders. They should all be ending with ".Tests"
84- 	 $outDir  =  Join-Path  $env: TF_OUT_DIR  - ChildPath $TFT_Configuration 
85- 	 $testFolders  =  Get-ChildItem  $outDir  - Directory - Filter $env: TF_TESTS_OUTDIR_PATTERN  |  % {$_.FullName  }
92+      $outDir  =  Join-Path  $env: TF_OUT_DIR  - ChildPath $TFT_Configuration 
93+      $testFolders  =  Get-ChildItem  $outDir  - Directory - Filter $env: TF_TESTS_OUTDIR_PATTERN  |  % {$_.FullName  }
8694
8795    #  Get test assemblies from these folders that match the pattern specified.
88- 	 foreach ($container  in  $testFolders )
89- 	 {
90- 		 $testContainer  =  Get-ChildItem  $container \*  - Recurse - Include $env: TF_UNITTEST_FILES_PATTERN ,  $env: TF_COMPONENTTEST_FILES_PATTERN ,  $env: TF_E2ETEST_FILES_PATTERN 
91- 		 
96+      foreach ($container  in  $testFolders )
97+      {
98+          $testContainer  =  Get-ChildItem  $container \*  - Recurse - Include $env: TF_UNITTEST_FILES_PATTERN ,  $env: TF_COMPONENTTEST_FILES_PATTERN ,  $env: TF_E2ETEST_FILES_PATTERN 
99+          
92100        $testContainerName  =  $testContainer.Name  
93101        $testContainerPath  =  $testContainer.FullName  
94102        $allContainers  +=  , " $testContainerName " 
95103
96104        if ($TFT_All )
97105        {
98- 			 if ($env: TF_NetCoreContainers  -Contains  $testContainerName )
99- 			 {
100- 				 $netCoreTestContainers  +=  , " $testContainerPath "   
101- 			 }
102-     		 else 
103- 			 {
104- 				 $testContainers  +=  , " $testContainerPath " 
105- 			 }
106+              if ($env: TF_NetCoreContainers  -Contains  $testContainerName )
107+              {
108+                  $netCoreTestContainers  +=  , " $testContainerPath "   
109+              }
110+              else 
111+              {
112+                  $testContainers  +=  , " $testContainerPath " 
113+              }
106114        }
107115        else  
108116        {
109117            if ($testContainerPath  -match  $TFT_Pattern )
110118            {
111-     		     if ($env: TF_NetCoreContainers  -Contains  $testContainerName )
112- 				 {
113- 					 $netCoreTestContainers  +=  , " $testContainerPath "   
114- 
115- 				 }
116- 				 else 
117- 				 {
118- 					 $testContainers  +=  , " $testContainerPath " 
119- 				 }
119+                  if ($env: TF_NetCoreContainers  -Contains  $testContainerName )
120+                  {
121+                      $netCoreTestContainers  +=  , " $testContainerPath "   
122+ 
123+                  }
124+                  else 
125+                  {
126+                      $testContainers  +=  , " $testContainerPath " 
127+                  }
120128            }
121129        }
122- 	 }
123- 						 
130+      }
131+                          
124132    if ($testContainers.Count   -gt  0  -Or  $netCoreTestContainers.Count   -gt  0 )
125133    {
126134        $testContainersString  =  [system.String ]::Join(" ," , $testContainers )
@@ -133,8 +141,8 @@ function Invoke-Test
133141        Write-Log  "     None of the test containers matched the pattern $TFT_Pattern ." 
134142        Write-Log  "     Test Containers available: $allContainersString ." 
135143    }
136- 	 
137- 	 Write-Log  " Run-Test: Complete. {$ ( Get-ElapsedTime ($timer )) }" 
144+      
145+      Write-Log  " Run-Test: Complete. {$ ( Get-ElapsedTime ($timer )) }" 
138146}
139147
140148function  Run-Test ([string []] $testContainers ,  [string []] $netCoreTestContainers )
@@ -146,52 +154,53 @@ function Run-Test([string[]] $testContainers, [string[]] $netCoreTestContainers)
146154    {
147155       $additionalArguments  +=  " /parallel" 
148156    }
149- 	 
150- 	  if ($testContainers.Count   -gt  0 )
151- 	  {
152- 	 	 if (! (Test-Path  $vstestPath ))
153- 	 	 {
154- 	 		 Write-Error  " Unable to find vstest.console.exe at $vstestPath . Test aborted." 
155- 	 	 }
156- 	 
157- 	 	 Write-Verbose  " $vstestPath  $testContainers  $additionalArguments  /logger:trx" 
158- 	 	 &  $vstestPath  $testContainers  $additionalArguments  / logger:trx
159- 
160- 	 	 if  ($lastExitCode  -ne  0 ) 
161- 	 	 {
162- 	 	     throw  " Tests failed." 
163- 	 	 }
164- 	  }
165- 	 
166- 	 if ($netCoreTestContainers.Count   -gt  0 )
167- 	 {
168- 		 Try 
169- 		 {
170- 			 Write-Verbose  " dotnet test $netCoreTestContainers  /framework:$TestFramework  $additionalArguments  /logger:trx" 
171- 			 &  dotnet test $netCoreTestContainers  / framework:$TestFramework  $additionalArguments  / logger:trx
172- 		 }
173- 
174- 		 Catch  [System.Management.Automation.CommandNotFoundException ]
175- 		 {
176- 			 Write-Error  " Unable to find dotnet.exe. Test aborted." 
177- 		 }
178- 
179- 		 if  ($lastExitCode  -ne  0 ) 
180- 		 {
181- 		     throw  " Tests failed." 
182- 		 }
183- 	 }
157+      
158+       if ($testContainers.Count   -gt  0 )
159+       {
160+          if (! (Test-Path  $vstestPath ))
161+          {
162+              Write-Error  " Unable to find vstest.console.exe at $vstestPath . Test aborted." 
163+          }
164+      
165+          Write-Verbose  " $vstestPath  $testContainers  $additionalArguments  /logger:trx" 
166+          &  $vstestPath  $testContainers  $additionalArguments  / logger:trx
167+ 
168+          if  ($lastExitCode  -ne  0 ) 
169+          {
170+              throw  " Tests failed." 
171+          }
172+       }
173+      
174+      if ($netCoreTestContainers.Count   -gt  0 )
175+      {
176+          Try 
177+          {
178+              Write-Verbose  " dotnet test $netCoreTestContainers  /framework:`" $TestFramework `"  $additionalArguments  /logger:trx" 
179+              &  dotnet test $netCoreTestContainers  / framework:" $TestFramework "   $additionalArguments  / logger:trx
180+          }
181+ 
182+          Catch  [System.Management.Automation.CommandNotFoundException ]
183+          {
184+              Write-Error  " Unable to find dotnet.exe. Test aborted." 
185+          }
186+ 
187+          if  ($lastExitCode  -ne  0 ) 
188+          {
189+              throw  " Tests failed." 
190+          }
191+      }
184192}
185193
186194function  Get-VSTestPath 
187195{
188196    $versionsFile  =  " $PSScriptRoot \build\TestFx.Versions.targets" 
189197    $TestPlatformVersion  =  (([XML ](Get-Content  $versionsFile )).Project.PropertyGroup.TestPlatformVersion).InnerText
190198
191- 	 $vsInstallPath  =  " $PSScriptRoot \..\packages\Microsoft.TestPlatform.$TestPlatformVersion \" 
192- 	 $vstestPath  =  Join-Path  - path $vsInstallPath  " tools\net451\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" 
193- 	 return  Resolve-Path  - path $vstestPath 
199+      $vsInstallPath  =  " $PSScriptRoot \..\packages\Microsoft.TestPlatform.$TestPlatformVersion \" 
200+      $vstestPath  =  Join-Path  - path $vsInstallPath  " tools\net451\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" 
201+      return  Resolve-Path  - path $vstestPath 
194202}
195203
196204Print- Help
205+ Install-DotNetCli 
197206Invoke-Test 
0 commit comments