diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 6cb0e7cd9..ca07e09e0 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -7,6 +7,12 @@ "commands": [ "ilverify" ] + }, + "microsoft.coyote.cli": { + "version": "1.5.1", + "commands": [ + "coyote" + ] } } } \ No newline at end of file diff --git a/.github/workflows/test-coyote.yml b/.github/workflows/test-coyote.yml index fcb0713cf..96c3a9faa 100644 --- a/.github/workflows/test-coyote.yml +++ b/.github/workflows/test-coyote.yml @@ -43,14 +43,14 @@ jobs: with: dotnet-version: '3.1.x' - name: Build Coyote projects - run: ./Scripts/build.ps1 -ci $true + run: ./Scripts/build.ps1 -ci shell: pwsh - name: Validate Coyote Rewriting if: ${{ matrix.platform == 'windows-latest' }} run: ./Tests/compare-rewriting-diff-logs.ps1 shell: pwsh - name: Run Coyote Tests - run: ./Scripts/run-tests.ps1 -ci $true + run: ./Scripts/run-tests.ps1 -ci shell: pwsh - name: Build and test Coyote NuGet packages if: ${{ matrix.platform == 'windows-latest' }} @@ -58,6 +58,11 @@ jobs: ./Scripts/create-nuget-packages.ps1 ./Scripts/test-cli-package.ps1 shell: pwsh + - name: Archive Coyote binaries + uses: actions/upload-artifact@v3 + with: + name: coyote-binaries + path: ./bin build-and-test-samples: name: Build and test Coyote samples needs: build-and-test @@ -73,8 +78,16 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: '6.0.x' - - name: Build and test Coyote samples + - name: Download Coyote binaries + uses: actions/download-artifact@v3 + with: + name: coyote-binaries + path: ./bin + - name: Build Coyote samples run: | - ./Samples/Scripts/build-tests.ps1 -local $true - dotnet ./Samples/Common/bin/net6.0/TestDriver.dll + ./Samples/Scripts/build.ps1 -local -nuget + ./Samples/Scripts/build-tests.ps1 -local -nuget + shell: pwsh + - name: Test Coyote samples + run: dotnet ./Samples/Common/bin/net6.0/TestDriver.dll shell: pwsh diff --git a/NuGet.config b/NuGet.config index e72df0513..9c6c3191a 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,11 +1,20 @@ + + + + + - - - - + + + + + + + + \ No newline at end of file diff --git a/Samples/Common/TestDriver/TestDriver.csproj b/Samples/Common/TestDriver/TestDriver.csproj index e7259356f..05ebac115 100644 --- a/Samples/Common/TestDriver/TestDriver.csproj +++ b/Samples/Common/TestDriver/TestDriver.csproj @@ -18,9 +18,12 @@ - + + + + diff --git a/Samples/Common/build.props b/Samples/Common/build.props index be1db337e..b9f61ceeb 100644 --- a/Samples/Common/build.props +++ b/Samples/Common/build.props @@ -7,6 +7,9 @@ 10.0 net6.0 False + False + True + False $(MSBuildThisFileDirectory) $(CodeAnalysisRuleSetLocation)\codeanalysis.ruleset diff --git a/Samples/NuGet.config b/Samples/NuGet.config new file mode 100644 index 000000000..e3105efc2 --- /dev/null +++ b/Samples/NuGet.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/README.md b/Samples/README.md index 68da715bb..f1b6d9a34 100644 --- a/Samples/README.md +++ b/Samples/README.md @@ -49,13 +49,19 @@ You can find the compiled binaries in the `bin` directory. You can use the `coyo automatically test these samples and find bugs. First, read how to use the tool [here](../get-started/using-coyote.md). Then, follow the instructions in each sample. -## Using the local Coyote binaries +## Using the local Coyote packages By default, the samples use the published `Microsoft.Coyote` [NuGet -package](https://www.nuget.org/packages/Microsoft.Coyote/). If you want to use the locally built -Coyote binaries instead, then run the following script in `powershell`: +package](https://www.nuget.org/packages/Microsoft.Coyote/). + +If you want instead to use the locally built Coyote binaries, then run the following script in +`powershell`: ``` -./Samples/Scripts/build.ps1 -local $true +./Samples/Scripts/build.ps1 -local ``` -Note: this can make debugging into the Coyote runtime possible. +Finally, if you want instead to use the locally built Coyote NuGet packages, then run the following +script in `powershell`: +``` +./Samples/Scripts/build.ps1 -local -nuget +``` diff --git a/Samples/Scripts/build-tests.ps1 b/Samples/Scripts/build-tests.ps1 index dcb10dbd7..9405ac5ba 100644 --- a/Samples/Scripts/build-tests.ps1 +++ b/Samples/Scripts/build-tests.ps1 @@ -2,13 +2,19 @@ param( [string]$dotnet="dotnet", [ValidateSet("Debug","Release")] [string]$configuration="Release", - [bool]$local = $false + [switch]$local, + [switch]$nuget ) -Import-Module $PSScriptRoot\..\..\Scripts\powershell\common.psm1 -Force +Import-Module $PSScriptRoot/../../Scripts/common.psm1 -Force Write-Comment -prefix "." -text "Building the Coyote samples" -color "yellow" +if ($local.IsPresent -and $nuget.IsPresent) { + # Restore the local coyote tool. + &dotnet tool restore +} + # Check that the expected .NET SDK is installed. $dotnet = "dotnet" $dotnet_sdk_path = FindDotNetSdkPath -dotnet $dotnet @@ -21,7 +27,7 @@ if ($null -eq $sdk_version) { } # Build the tests for the samples. -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\Common\TestDriver\TestDriver.csproj" ` - -config $configuration -local $local +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../Common/TestDriver/TestDriver.csproj" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent Write-Comment -prefix "." -text "Successfully built the Coyote samples" -color "green" diff --git a/Samples/Scripts/build.ps1 b/Samples/Scripts/build.ps1 index e3d3d3f5d..a4749224a 100644 --- a/Samples/Scripts/build.ps1 +++ b/Samples/Scripts/build.ps1 @@ -2,13 +2,19 @@ param( [string]$dotnet="dotnet", [ValidateSet("Debug","Release")] [string]$configuration="Release", - [bool]$local = $false + [switch]$local, + [switch]$nuget ) -Import-Module $PSScriptRoot\..\..\Scripts\powershell\common.psm1 -Force +Import-Module $PSScriptRoot/../../Scripts/common.psm1 -Force Write-Comment -prefix "." -text "Building the Coyote samples" -color "yellow" +if ($local.IsPresent -and $nuget.IsPresent) { + # Restore the local coyote tool. + &dotnet tool restore +} + # Check that the expected .NET SDK is installed. $dotnet = "dotnet" $dotnet_sdk_path = FindDotNetSdkPath -dotnet $dotnet @@ -21,31 +27,31 @@ if ($null -eq $sdk_version) { } # Build the task-based samples. -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\AccountManager\AccountManager.sln" ` - -config $configuration -local $local -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\BoundedBuffer\BoundedBuffer.sln" ` - -config $configuration -local $local -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\CoffeeMachineTasks\CoffeeMachineTasks.sln" ` - -config $configuration -local $local +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../AccountManager/AccountManager.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../BoundedBuffer/BoundedBuffer.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../CoffeeMachineTasks/CoffeeMachineTasks.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent # Build the actor samples. -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\HelloWorldActors\HelloWorldActors.sln" ` - -config $configuration -local $local -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\CoffeeMachineActors\CoffeeMachineActors.sln" ` - -config $configuration -local $local -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\DrinksServingRobotActors\DrinksServingRobotActors.sln" ` - -config $configuration -local $local -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\CloudMessaging\CloudMessaging.sln" ` - -config $configuration -local $local -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\Timers\Timers.sln" ` - -config $configuration -local $local -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\Monitors\Monitors.sln" ` - -config $configuration -local $local +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../HelloWorldActors/HelloWorldActors.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../CoffeeMachineActors/CoffeeMachineActors.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../DrinksServingRobotActors/DrinksServingRobotActors.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../CloudMessaging/CloudMessaging.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../Timers/Timers.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../Monitors/Monitors.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent # Build the web app samples. -# Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\WebApps\ImageGalleryAspNet\ImageGallery.sln" ` - # -config $configuration -local $local -Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot\..\WebApps\PetImagesAspNet\PetImages.sln" ` - -config $configuration -local $local +# Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../WebApps/ImageGalleryAspNet/ImageGallery.sln" ` + # -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent +Invoke-DotnetBuild -dotnet $dotnet -solution "$PSScriptRoot/../WebApps/PetImagesAspNet/PetImages.sln" ` + -config $configuration -local $local.IsPresent -nuget $nuget.IsPresent Write-Comment -prefix "." -text "Successfully built the Coyote samples" -color "green" diff --git a/Samples/WebApps/PetImagesAspNet/PetImages.Tests/PetImages.Tests.csproj b/Samples/WebApps/PetImagesAspNet/PetImages.Tests/PetImages.Tests.csproj index 12740d3ad..39f989ec7 100644 --- a/Samples/WebApps/PetImagesAspNet/PetImages.Tests/PetImages.Tests.csproj +++ b/Samples/WebApps/PetImagesAspNet/PetImages.Tests/PetImages.Tests.csproj @@ -15,9 +15,12 @@ - + + + + diff --git a/Scripts/CI/azure-nuget-sign-publish.yml b/Scripts/CI/azure-nuget-sign-publish.yml index ef2880a75..5c2f1accb 100644 --- a/Scripts/CI/azure-nuget-sign-publish.yml +++ b/Scripts/CI/azure-nuget-sign-publish.yml @@ -27,7 +27,7 @@ steps: inputs: targetType: filePath filePath: '.\Scripts\build.ps1' - arguments: "-ci $true" + arguments: "-ci" failOnStderr: true pwsh: true diff --git a/Scripts/build.ps1 b/Scripts/build.ps1 index 53ce2dcf2..8257a378f 100644 --- a/Scripts/build.ps1 +++ b/Scripts/build.ps1 @@ -4,12 +4,12 @@ param( [ValidateSet("Debug", "Release")] [string]$configuration = "Release", - [bool]$ci = $false + [switch]$ci ) $ScriptDir = $PSScriptRoot -Import-Module $ScriptDir/powershell/common.psm1 -Force +Import-Module $ScriptDir/common.psm1 -Force Write-Comment -prefix "." -text "Building Coyote" -color "yellow" @@ -34,10 +34,10 @@ if ($null -eq $sdk_version) { } Write-Comment -prefix "..." -text "Using configuration '$configuration'" -$solution = Join-Path -Path $ScriptDir -ChildPath "\.." -AdditionalChildPath "Coyote.sln" +$solution = Join-Path -Path $ScriptDir -ChildPath ".." -AdditionalChildPath "Coyote.sln" $command = "build -c $configuration $solution /p:Platform=""Any CPU""" -if ($ci) { +if ($ci.IsPresent) { # Build any supported .NET versions that are installed on this machine. if ($version_net4) { # Build .NET Framework 4.x as well as the latest version. diff --git a/Scripts/powershell/common.psm1 b/Scripts/common.psm1 similarity index 89% rename from Scripts/powershell/common.psm1 rename to Scripts/common.psm1 index b250d8808..fb5443b99 100644 --- a/Scripts/powershell/common.psm1 +++ b/Scripts/common.psm1 @@ -25,16 +25,22 @@ function Invoke-CoyoteTool([String]$cmd, [String]$dotnet, [String]$framework, [S } # Builds the specified .NET project -function Invoke-DotnetBuild([String]$dotnet, [String]$solution, [String]$config, [bool]$local) { +function Invoke-DotnetBuild([String]$dotnet, [String]$solution, [String]$config, [bool]$local, [bool]$nuget) { Write-Comment -prefix "..." -text "Building $solution" - $command = "build -c $config $solution" - if ($local) { - $command = "$command /p:UseLocalCoyote=true" + $nuget_config_file = "$PSScriptRoot/../NuGet.config" + $restore_command = "restore $solution" + $build_command = "build -c $config $solution --no-restore" + if ($local -and $nuget) { + $restore_command = "$restore_command --configfile $nuget_config_file" + $build_command = "$build_command /p:UseLocalNugetPackages=true " + } elseif ($local) { + $restore_command = "$restore_command --configfile $nuget_config_file" + $build_command = "$build_command /p:UseLocalCoyote=true" } - $error_msg = "Failed to build $solution" - Invoke-ToolCommand -tool $dotnet -cmd $command -error_msg $error_msg + Invoke-ToolCommand -tool $dotnet -cmd $restore_command -error_msg "Failed to restore $solution" + Invoke-ToolCommand -tool $dotnet -cmd $build_command -error_msg "Failed to build $solution" } # Runs the specified .NET test using the specified framework. @@ -71,16 +77,6 @@ function Invoke-ToolCommand([String]$tool, [String]$cmd, [String]$error_msg) { } } -function TraverseLink($path) { - $item = Get-Item $path - if ($item.LinkType -eq "SymbolicLink") { - $target = $item.Target - Write-Host "Traversing link $target" - return TraverseLink($target) - } - return $path -} - function FindProgram([String]$name) { $result = $null $path = $ENV:PATH.split([System.IO.Path]::PathSeparator) | ForEach-Object { @@ -137,7 +133,7 @@ function FindDotNetRuntimePath([String]$dotnet, [String]$runtime) { # Finds the dotnet SDK version. function FindDotNetSdkVersion([String]$dotnet_sdk_path) { - $globalJson = Join-Path -Path $PSScriptRoot -ChildPath ".." -AdditionalChildPath @("..", "global.json") + $globalJson = Join-Path -Path $PSScriptRoot -ChildPath ".." -AdditionalChildPath @("global.json") $json = Get-Content $globalJson | Out-String | ConvertFrom-Json $global_version = $json.sdk.version Write-Comment -prefix "..." -text "Searching for .NET SDK version '$global_version' in '$dotnet_sdk_path'" @@ -153,7 +149,7 @@ function FindDotNetSdkVersion([String]$dotnet_sdk_path) { # Finds the dotnet runtime version. function FindDotNetRuntimeVersion([String]$dotnet_runtime_path) { - $globalJson = Join-Path -Path $PSScriptRoot -ChildPath ".." -AdditionalChildPath @("..", "global.json") + $globalJson = Join-Path -Path $PSScriptRoot -ChildPath ".." -AdditionalChildPath @("global.json") $json = Get-Content $globalJson | Out-String | ConvertFrom-Json $global_version = $json.sdk.version return FindMatchingVersion -path $dotnet_runtime_path -version $global_version diff --git a/Scripts/create-nuget-packages.ps1 b/Scripts/create-nuget-packages.ps1 index bd978a50c..e7484ca17 100644 --- a/Scripts/create-nuget-packages.ps1 +++ b/Scripts/create-nuget-packages.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -Import-Module $PSScriptRoot\powershell\common.psm1 -Force +Import-Module $PSScriptRoot/common.psm1 -Force # Check that NuGet.exe is installed. $nuget = "nuget" @@ -13,13 +13,13 @@ if (-not (Get-Command $nuget -errorAction SilentlyContinue)) { Write-Comment -prefix "." -text "Creating the Coyote NuGet packages" -color "yellow" # Extract the package version. -$version_file = "$PSScriptRoot\..\Common\version.props" +$version_file = "$PSScriptRoot/../Common/version.props" $version_node = Select-Xml -Path $version_file -XPath "/" | Select-Object -ExpandProperty Node $version = $version_node.Project.PropertyGroup.VersionPrefix $version_suffix = $version_node.Project.PropertyGroup.VersionSuffix # Setup the command line options for nuget pack. -$cmd_options = "-OutputDirectory $PSScriptRoot\..\bin\nuget -Version $version" +$cmd_options = "-OutputDirectory $PSScriptRoot/../bin/nuget -Version $version" $cmd_options = "$cmd_options -Symbols -SymbolPackageFormat snupkg" if ($version_suffix) { $cmd_options = "$cmd_options -Suffix $version_suffix" @@ -27,19 +27,19 @@ if ($version_suffix) { Write-Comment -prefix "..." -text "Creating the 'Microsoft.Coyote' package" -$command = "pack $PSScriptRoot\NuGet\Coyote.nuspec $cmd_options" +$command = "pack $PSScriptRoot/NuGet/Coyote.nuspec $cmd_options" $error_msg = "Failed to create the Coyote NuGet package" Invoke-ToolCommand -tool $nuget -cmd $command -error_msg $error_msg Write-Comment -prefix "..." -text "Creating the 'Microsoft.Coyote.Test' package" -$command = "pack $PSScriptRoot\NuGet\Coyote.Test.nuspec $cmd_options" +$command = "pack $PSScriptRoot/NuGet/Coyote.Test.nuspec $cmd_options" $error_msg = "Failed to create the Coyote Test NuGet package" Invoke-ToolCommand -tool $nuget -cmd $command -error_msg $error_msg Write-Comment -prefix "..." -text "Creating the 'Microsoft.Coyote.CLI' package" -$command = "pack $PSScriptRoot\NuGet\Coyote.CLI.nuspec $cmd_options -Tool" +$command = "pack $PSScriptRoot/NuGet/Coyote.CLI.nuspec $cmd_options -Tool" $error_msg = "Failed to create the Coyote CLI NuGet package" Invoke-ToolCommand -tool $nuget -cmd $command -error_msg $error_msg diff --git a/Scripts/encode_nuget_sign_certificate.ps1 b/Scripts/encode_nuget_sign_certificate.ps1 index 459f18f84..c0ae68f3c 100644 --- a/Scripts/encode_nuget_sign_certificate.ps1 +++ b/Scripts/encode_nuget_sign_certificate.ps1 @@ -8,13 +8,13 @@ param( $ScriptDir = $PSScriptRoot -Import-Module $ScriptDir\powershell\common.psm1 -Force +Import-Module $ScriptDir/common.psm1 -Force Write-Comment -prefix "." -text "Encoding NuGet signing certificate" -color "yellow" Write-Comment -prefix "..." -text "You might need to run 'az login' first" -color "blue" $guid = [GUID]::NewGuid().ToString() -$result_file = "$ScriptDir\$guid" +$result_file = "$ScriptDir/$guid" Write-Host $result_file # # The "Secret Identifier" url from the certificate details. diff --git a/Scripts/run-benchmark-history.ps1 b/Scripts/run-benchmark-history.ps1 index 17f31337c..15e287bcb 100644 --- a/Scripts/run-benchmark-history.ps1 +++ b/Scripts/run-benchmark-history.ps1 @@ -11,37 +11,37 @@ param( ) $ScriptDir = $PSScriptRoot -$RootDir = "$ScriptDir\.." -Import-Module $ScriptDir\powershell\common.psm1 -Force +$RootDir = "$ScriptDir/.." +Import-Module $ScriptDir/common.psm1 -Force # save the current benchmark code in a temp folder. -$source = "$ENV:TEMP\Benchmark" +$source = "$ENV:TEMP/Benchmark" if (Test-Path $source) { Remove-Item $source -Recurse -Force } -if (Test-Path "$RootDir\tests\Performance.Tests\bin") { - Remove-Item "$RootDir\tests\Performance.Tests\bin" -Recurse -Force +if (Test-Path "$RootDir/tests/Performance.Tests/bin") { + Remove-Item "$RootDir/tests/Performance.Tests/bin" -Recurse -Force } -if (Test-Path "$RootDir\tests\Performance.Tests\obj") { - Remove-Item "$RootDir\tests\Performance.Tests\obj" -Recurse -Force +if (Test-Path "$RootDir/tests/Performance.Tests/obj") { + Remove-Item "$RootDir/tests/Performance.Tests/obj" -Recurse -Force } Write-Host "Saving current benchmark source code" -Copy-Item "$RootDir\Tests\Performance.Tests" -Recurse "$source\Tests\Performance.Tests" -Copy-Item "$RootDir\Tools\BenchmarkRunner" -Recurse "$source\Tools\BenchmarkRunner" +Copy-Item "$RootDir/Tests/Performance.Tests" -Recurse "$source/Tests/Performance.Tests" +Copy-Item "$RootDir/Tools/BenchmarkRunner" -Recurse "$source/Tools/BenchmarkRunner" function RestoreBenchmark() { Write-Host "Restoring latest benchmark source code" - Remove-Item "$RootDir\Tests\Performance.Tests" -Recurse -Force - Copy-Item "$source\Tests\Performance.Tests" -Recurse "$RootDir\Tests\Performance.Tests" - Remove-Item "$RootDir\Tools\BenchmarkRunner" -Recurse -Force - Copy-Item "$source\Tools\BenchmarkRunner" -Recurse "$RootDir\Tools\BenchmarkRunner" + Remove-Item "$RootDir/Tests/Performance.Tests" -Recurse -Force + Copy-Item "$source/Tests/Performance.Tests" -Recurse "$RootDir/Tests/Performance.Tests" + Remove-Item "$RootDir/Tools/BenchmarkRunner" -Recurse -Force + Copy-Item "$source/Tools/BenchmarkRunner" -Recurse "$RootDir/Tools/BenchmarkRunner" Invoke-Expression "sed -i 's/\\Performance.Tests.csproj/\\Microsoft.Coyote.Performance.Tests.csproj/' $RootDir\Coyote.sln" } -$benchmarks_dir = "$RootDir\Tools\BenchmarkRunner\bin\net6.0" +$benchmarks_dir = "$RootDir/Tools/BenchmarkRunner/bin/net6.0" $benchmark_runner = "BenchmarkRunner.exe" $index = 0 @@ -54,8 +54,8 @@ function ProcessCommit($commit) { Sleep 5 Invoke-ToolCommand -tool "dotnet" -cmd "build-server shutdown" Sleep 5 - $artifacts_dir = "$RootDir\benchmark_$commit" - Invoke-Expression "$benchmarks_dir\$benchmark_runner -outdir $artifacts_dir -commit $commit -cosmos $filter" + $artifacts_dir = "$RootDir/benchmark_$commit" + Invoke-Expression "$benchmarks_dir/$benchmark_runner -outdir $artifacts_dir -commit $commit -cosmos $filter" if (-not (Test-Path $artifacts_dir)) { Write-Error "Unable to find the benchmark results ($artifacts_dir)." Exit 1 diff --git a/Scripts/run-benchmarks.ps1 b/Scripts/run-benchmarks.ps1 index c64e89c3b..88f22ce12 100644 --- a/Scripts/run-benchmarks.ps1 +++ b/Scripts/run-benchmarks.ps1 @@ -7,7 +7,7 @@ param( [string]$local = "" ) -Import-Module $PSScriptRoot\powershell\common.psm1 -Force +Import-Module $PSScriptRoot/common.psm1 -Force $history = Invoke-Expression "git log --pretty=oneline -n 1" $words = $history.Split(' ') @@ -22,20 +22,20 @@ else { $cosmos = "" } -$current_dir = (Get-Item -Path ".\").FullName -$benchmarks_dir = "$PSScriptRoot\..\Tools\BenchmarkRunner\bin\net6.0" +$current_dir = (Get-Item -Path "./").FullName +$benchmarks_dir = "$PSScriptRoot/../Tools/BenchmarkRunner/bin/net6.0" $benchmark_runner = "BenchmarkRunner.exe" -$artifacts_dir = "$current_dir\benchmark_$commit" +$artifacts_dir = "$current_dir/benchmark_$commit" if (-Not (Test-Path -Path "$benchmarks_dir")) { throw "Please build coyote project first" } -$custom = "D:\git\lovettchris\BenchmarkDotNet\src\BenchmarkDotNet\bin\Release\netstandard2.0" +$custom = "D:/git/lovettchris/BenchmarkDotNet/src/BenchmarkDotNet/bin/Release/netstandard2.0" if (Test-Path -Path $custom) { Write-Host "==> Using a patched version of BenchmarkDotNet..." - Copy-Item "$custom\BenchmarkDotNet.dll" "$benchmarks_dir\BenchmarkDotNet.dll" -Force - Copy-Item "$custom\BenchmarkDotNet.Annotations.dll" "$benchmarks_dir\BenchmarkDotNet.Annotations.dll" -Force + Copy-Item "$custom/BenchmarkDotNet.dll" "$benchmarks_dir/BenchmarkDotNet.dll" -Force + Copy-Item "$custom/BenchmarkDotNet.Annotations.dll" "$benchmarks_dir/BenchmarkDotNet.Annotations.dll" -Force } if (Test-Path -Path $artifacts_dir -PathType Container) { @@ -44,7 +44,7 @@ if (Test-Path -Path $artifacts_dir -PathType Container) { Write-Comment -prefix "." -text "Running the Coyote performance benchmarks, saving to $artifacts_dir" -color "yellow" -Invoke-Expression "$benchmarks_dir\$benchmark_runner -outdir $artifacts_dir -commit $commit $cosmos" +Invoke-Expression "$benchmarks_dir/$benchmark_runner -outdir $artifacts_dir -commit $commit $cosmos" Write-Comment -prefix "." -text "Done" -color "green" @@ -55,9 +55,9 @@ if ($local -ne "") { New-Item -Path $local -ItemType Directory } $index = 1 - while (Test-Path -Path "$local\benchmark_$commit.$index") { + while (Test-Path -Path "$local/benchmark_$commit.$index") { $index = $index + 1 } - Move-Item -Path $artifacts_dir -Destination "$local\benchmark_$commit.$index" + Move-Item -Path $artifacts_dir -Destination "$local/benchmark_$commit.$index" } diff --git a/Scripts/run-tests.ps1 b/Scripts/run-tests.ps1 index d2b1844a5..59e8bc411 100644 --- a/Scripts/run-tests.ps1 +++ b/Scripts/run-tests.ps1 @@ -10,10 +10,10 @@ param( [string]$logger = "", [ValidateSet("quiet", "minimal", "normal", "detailed", "diagnostic")] [string]$v = "normal", - [bool]$ci = $false + [switch]$ci ) -Import-Module $PSScriptRoot/powershell/common.psm1 -Force +Import-Module $PSScriptRoot/common.psm1 -Force $all_frameworks = (Get-Variable "framework").Attributes.ValidValues $targets = [ordered]@{ @@ -46,7 +46,7 @@ foreach ($kvp in $targets.GetEnumerator()) { $frameworks = Get-ChildItem -Path "$PSScriptRoot/../Tests/$($kvp.Value)/bin" | ` Where-Object Name -CIn $all_frameworks | Select-Object -expand Name foreach ($f in $frameworks) { - if ((-not $ci) -and ($f -ne $framework)) { + if ((-not $ci.IsPresent) -and ($f -ne $framework)) { continue } diff --git a/Scripts/test-cli-package.ps1 b/Scripts/test-cli-package.ps1 index 42824d5b9..5408f1258 100644 --- a/Scripts/test-cli-package.ps1 +++ b/Scripts/test-cli-package.ps1 @@ -3,14 +3,12 @@ $ErrorActionPreference = 'Stop' -Import-Module $PSScriptRoot\powershell\common.psm1 -Force +Import-Module $PSScriptRoot/common.psm1 -Force Write-Comment -prefix "." -text "Running the Coyote CLI package test" -color "yellow" $root = $ENV:SYSTEMROOT if ($null -ne $root -and $root.ToLower().Contains("windows")) { - $coyote_path = $ENV:PATH.split([System.IO.Path]::PathSeparator) | Where-Object { Test-Path "$_/coyote.exe" } - if (-not "$PSScriptRoot/../temp/coyote" -eq "") { Write-Comment -prefix "..." -text "Uninstalling the Microsoft.Coyote.CLI package" dotnet tool uninstall Microsoft.Coyote.CLI --tool-path temp @@ -20,8 +18,6 @@ if ($null -ne $root -and $root.ToLower().Contains("windows")) { dotnet tool install --add-source $PSScriptRoot/../bin/nuget Microsoft.Coyote.CLI --no-cache --tool-path temp } else { - $coyote_path = $ENV:PATH.split([System.IO.Path]::PathSeparator) | Where-Object { Test-Path "$_/coyote" } - if (-not "$PSScriptRoot/../temp/coyote" -eq "") { Write-Comment -prefix "..." -text "Uninstalling the coyote .NET tool" dotnet tool uninstall coyote --tool-path temp diff --git a/Tests/compare-rewriting-diff-logs.ps1 b/Tests/compare-rewriting-diff-logs.ps1 index 8c985cb3e..4c0eef8ea 100644 --- a/Tests/compare-rewriting-diff-logs.ps1 +++ b/Tests/compare-rewriting-diff-logs.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -Import-Module $PSScriptRoot/../Scripts/powershell/common.psm1 -Force +Import-Module $PSScriptRoot/../Scripts/common.psm1 -Force $framework = "net6.0" $targets = [ordered]@{ diff --git a/Tests/get-rewriting-diff-logs.ps1 b/Tests/get-rewriting-diff-logs.ps1 index 02af68cf0..70a0485c8 100644 --- a/Tests/get-rewriting-diff-logs.ps1 +++ b/Tests/get-rewriting-diff-logs.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -Import-Module $PSScriptRoot/../Scripts/powershell/common.psm1 -Force +Import-Module $PSScriptRoot/../Scripts/common.psm1 -Force $framework = "net6.0" $targets = [ordered]@{