Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "test": { "runner": "Microsoft.Testing.Platform" } }
95 changes: 57 additions & 38 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function GenerateRunSettings([String] $framework, [String] $platform, [String] $
# <Parameter name="FRAMEWORK" value="net462" />
# <Parameter name="CONFIGURATION" value="Release" />
# </TestRunParameters>
# <NUnit>
# <Verbosity>-1</Verbosity>
# </NUnit>
# </RunSettings>

$dec = $doc.CreateXmlDeclaration("1.0","UTF-8",$null)
Expand Down Expand Up @@ -80,6 +83,12 @@ function GenerateRunSettings([String] $framework, [String] $platform, [String] $
$testRunParameters.AppendChild($parameter) | Out-Null
}

$nunit = $doc.CreateElement("NUnit")
$runSettings.AppendChild($nunit) | Out-Null
$verbosity = $doc.CreateElement("Verbosity")
$verbosity.InnerText = "-1"
$nunit.AppendChild($verbosity) | Out-Null

$doc.AppendChild($runSettings) | Out-Null

$fileName = [System.IO.Path]::Combine($_BASEDIR, "tests", "IronPython.Tests", "runsettings.$framework.xml")
Expand Down Expand Up @@ -113,6 +122,7 @@ function RunTestTasks($tasks) {
}

$testScript = {
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
& dotnet test $args
# pass the status out in case of failure
if($LastExitCode -ne 0) {
Expand All @@ -123,46 +133,55 @@ function RunTestTasks($tasks) {
# create initial jobs
$bgJobs = @{}
$nextJob = 0
for ($i = 0; $i -lt $maxJobs; $i++) {
$j = Start-Job -ScriptBlock $testScript -ArgumentList $tasks[$nextJob].params
$bgJobs[$j] = $nextJob;
$nextJob += 1
}

$failedTests = @()
while ($bgJobs.values.Count -gt 0) {
$finished = Wait-Job -Any -Timeout 10 -Job @($bgJobs.keys)

# redirect output
foreach ($j in $bgJobs.keys) {
Receive-Job $j | ForEach-Object { "$($tasks[$bgJobs.$j].name) $_" }
try {
for ($i = 0; $i -lt $maxJobs; $i++) {
$j = Start-Job -ScriptBlock $testScript -ArgumentList $tasks[$nextJob].params
$bgJobs[$j] = $nextJob;
$nextJob += 1
}

# clean up finished jobs and create new ones
if ($null -ne $finished) {
$testName = $tasks[$bgJobs.$finished].name
Write-Host
if ($finished.State -eq 'Failed') {
Write-Host -ForegroundColor Red "$testName failed"
$global:Result = $finished.ChildJobs[0].JobStateInfo.Reason.ErrorRecord.TargetObject
$failedTests += $testName
} else {
Write-Host "$testName succeeded"
}
$failedTests = @()
while ($bgJobs.values.Count -gt 0) {
$finished = Wait-Job -Any -Timeout 10 -Job @($bgJobs.keys)

$bgJobs.Remove($finished)
Remove-Job $finished
if ($nextJob -lt $tasks.Count) {
$j = Start-Job -ScriptBlock $testScript -ArgumentList $tasks[$nextJob].params
$bgJobs[$j] = $nextJob;
$nextJob += 1
# redirect output
foreach ($j in $bgJobs.keys) {
Receive-Job $j | ForEach-Object { "$($tasks[$bgJobs.$j].name) $_" }
}
Write-Host "$($bgJobs.Count) jobs running: $(($bgJobs.values | ForEach-Object {$tasks[$_].name}) -Join ", ")"
Write-Host "$($tasks.Count - $nextJob) jobs pending: $(($nextJob..$tasks.Count | ForEach-Object {$tasks[$_].name}) -Join ", ")"
if ($failedTests) {
Write-Host -ForegroundColor Red "$($failedTests.Count) jobs failed: $($failedTests -Join ", ")"

# clean up finished jobs and create new ones
if ($null -ne $finished) {
$testName = $tasks[$bgJobs.$finished].name
Write-Host
if ($finished.State -eq 'Failed') {
Write-Host -ForegroundColor Red "$testName failed"
$global:Result = $finished.ChildJobs[0].JobStateInfo.Reason.ErrorRecord.TargetObject
$failedTests += $testName
} else {
Write-Host "$testName succeeded"
}

$bgJobs.Remove($finished)
Remove-Job $finished
if ($nextJob -lt $tasks.Count) {
$j = Start-Job -ScriptBlock $testScript -ArgumentList $tasks[$nextJob].params
$bgJobs[$j] = $nextJob;
$nextJob += 1
}
Write-Host "$($bgJobs.Count) jobs running: $(($bgJobs.values | ForEach-Object {$tasks[$_].name}) -Join ", ")"
Write-Host "$($tasks.Count - $nextJob) jobs pending: $(($nextJob..$tasks.Count | ForEach-Object {$tasks[$_].name}) -Join ", ")"
if ($failedTests) {
Write-Host -ForegroundColor Red "$($failedTests.Count) jobs failed: $($failedTests -Join ", ")"
}
Write-Host
}
Write-Host
}
} finally {
# on Ctrl+C, the jobs and the test processes they started would otherwise keep running
if ($bgJobs.Count -gt 0) {
Write-Host -ForegroundColor Yellow "Stopping $($bgJobs.Count) running job(s)"
$bgJobs.Keys | Stop-Job
$bgJobs.Keys | Remove-Job
}
}
}
Expand All @@ -177,7 +196,7 @@ function Test([String] $target, [String] $configuration, [String[]] $frameworks,
$runSettings = GenerateRunSettings $framework $platform $configuration $runIgnored

function createTask($filtername, $filter) {
[Object[]] $args = @("$_BASEDIR/tests/IronPython.Tests/IronPython.Tests.csproj", '-f', "$framework", '-o', "$_BASEDIR/bin/$configuration/$framework", '-c', "$configuration", '--no-build', '-v', 'n', '-l', "trx;LogFileName=$filtername-$framework-$configuration-result.trx", '-s', "$runSettings", "--filter=$filter");
[Object[]] $args = @('--project', "$_BASEDIR/tests/IronPython.Tests/IronPython.Tests.csproj", '-f', "$framework", '-c', "$configuration", '--no-build', '--output', 'Detailed', '--show-stdout', 'All', '--show-stderr', 'All', '--report-trx', '--report-trx-filename', "$filtername-$framework-$configuration-result.trx", '--results-directory', "$_BASEDIR/tests/IronPython.Tests/TestResults", '--settings', "$runSettings", '--filter', "$filter");
Write-Host "Enqueue [$framework $filtername]:"
Write-Host "dotnet test $args"
Write-Host
Expand All @@ -196,9 +215,9 @@ function Test([String] $target, [String] $configuration, [String[]] $frameworks,
"cpython" { $tasks += createTask "cpython" "TestCategory=CPython" }
default {
if ($filter.ToLower().StartsWith('ironpython')) {
$tasks += createTask "query" "TestCategory=IronPython&Name=$framework.$filter"
$tasks += createTask "query" "TestCategory=IronPython&Name=$framework.IronPython$($filter.Substring(10))"
} elseif ($filter.ToLower().StartsWith('cpython')) {
$tasks += createTask "query" "TestCategory=CPython&Name=$framework.$filter"
$tasks += createTask "query" "TestCategory=CPython&Name=$framework.CPython$($filter.Substring(7))"
} else {
$tasks += createTask "query" $filter
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython/IronPython.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</ItemGroup>

<ItemGroup Condition="'$(IsFullFramework)' == 'true' OR '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Memory" Version="4.6.3" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion tests/IronPython.Tests/Cases/CaseExecuter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using System.Text.RegularExpressions;
using System.Threading;

using IronPython;
using IronPython.Hosting;
using IronPython.Runtime;
using IronPython.Runtime.Exceptions;
Expand Down
1 change: 0 additions & 1 deletion tests/IronPython.Tests/Cases/CaseGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.IO;
using System.Runtime.InteropServices;

using IronPython;
using IronPythonTest.Util;

using NUnit.Framework;
Expand Down
17 changes: 14 additions & 3 deletions tests/IronPython.Tests/IronPython.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<PropertyGroup>
<TargetFrameworks>net462;net8.0;net10.0</TargetFrameworks>
<PreventStaging>true</PreventStaging>
<OutputType>Exe</OutputType>
<EnableNUnitRunner>true</EnableNUnitRunner>

<MeziantouPolyfill_IncludedPolyfills>
M:System.IO.Path.GetRelativePath(System.String, System.String);
</MeziantouPolyfill_IncludedPolyfills>
Expand All @@ -15,9 +18,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.14.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageReference Include="NUnit" Version="4.5.1" />
<PackageReference Include="NUnit3TestAdapter" Version="6.3.1" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="2.5.3" />
<PackageReference Include="Microsoft.Testing.Extensions.VSTestBridge" Version="2.5.3" />
</ItemGroup>

<ItemGroup>
Expand All @@ -32,6 +37,12 @@
</PackageReference>
</ItemGroup>

<!-- Run .NET Framework tests with Mono on Linux/macOS -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net462' and '$(OS)' != 'Windows_NT'">
<RunCommand Condition="'$(RunCommand)' == ''">mono</RunCommand>
<RunArguments Condition="'$(RunArguments)' == ''">"$(TargetPath)" $(StartArguments)</RunArguments>
</PropertyGroup>

<Import Project="$(AfterTargetFiles)" />
<Target Name="AfterBuildEnds" AfterTargets="AfterBuild" DependsOnTargets="$(AfterTargets)" />

Expand Down
1 change: 0 additions & 1 deletion tests/IronPython.Tests/Stress/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.Scripting.Generation;
using Microsoft.Scripting.Hosting;

using IronPython;
using IronPython.Hosting;

using NUnit.Framework;
Expand Down
Loading