Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d746eb

Browse files
author
dse
committed
NetCoreApp 2.0 embedding tests fixed and added to CI. + Other small fixes.
1 parent 41e9fa3 commit 6d746eb

10 files changed

+48
-13
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ install:
169169
script:
170170
- python -m pytest
171171
- mono $NUNIT_PATH src/embed_tests/bin/Python.EmbeddingTest.dll
172+
- dotnet src/embed_tests/bin/netcoreapp2.0_publish/Python.EmbeddingTest.dll
172173

173174
after_script:
174175
# Uncomment if need to geninterop, ie. py37 final

ci/appveyor_run_tests.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ if ($CS_STATUS -ne 0) {
4444
Write-Host "Embedded tests failed" -ForegroundColor "Red"
4545
}
4646

47+
# Run Embedded tests for netcoreapp2.0 (OpenCover currently does not supports dotnet core)
48+
Write-Host ("Starting embedded tests for netcoreapp2.0") -ForegroundColor "Green"
49+
&dotnet .\src\embed_tests\bin\netcoreapp2.0_publish\Python.EmbeddingTest.dll
50+
$CS_STATUS = $LastExitCode
51+
if ($CS_STATUS -ne 0) {
52+
Write-Host "Embedded tests for netcoreapp2.0 failed" -ForegroundColor "Red"
53+
}
54+
4755
# Set exit code to fail if either Python or Embedded tests failed
4856
if ($PYTHON_STATUS -ne 0 -or $CS_STATUS -ne 0) {
4957
Write-Host "Tests failed" -ForegroundColor "Red"

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ def build_extension(self, ext):
257257

258258
subprocess.check_call(" ".join(cmd + ["/t:Clean"]), shell=use_shell)
259259
subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell)
260+
if DEVTOOLS == "dotnet" or DEVTOOLS == "MsDev15":
261+
subprocess.check_call(" ".join(cmd + ["/t:Console_15:publish;Python_EmbeddingTest_15:publish", "/p:TargetFramework=netcoreapp2.0"]), shell=use_shell)
260262

261263
if DEVTOOLS == "Mono" or DEVTOOLS == "dotnet":
262264
self._build_monoclr()

src/clrmodule/clrmodule.15.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<NoWarn>1591</NoWarn>
2323
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
2424
<PythonBuildDir Condition=" '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
25-
<PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)$(TargetFramework)\</PythonBuildDir>
25+
<PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PythonBuildDir>
2626
<LangVersion>6</LangVersion>
2727
<ErrorReport>prompt</ErrorReport>
2828
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>

src/console/Console.15.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
2222
<NoWarn>1591</NoWarn>
2323
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
24-
<PythonBuildDir Condition=" '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
25-
<PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)$(TargetFramework)\</PythonBuildDir>
26-
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)</PublishDir>
24+
<PythonBuildDir Condition="'$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
25+
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PublishDir>
2726
<LangVersion>6</LangVersion>
2827
<ApplicationIcon>python-clear.ico</ApplicationIcon>
2928
<ErrorReport>prompt</ErrorReport>

src/embed_tests/Program.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Reflection;
3+
4+
using NUnit.Common;
5+
6+
using NUnitLite;
7+
8+
namespace Python.EmbeddingTest
9+
{
10+
public class Program
11+
{
12+
public static int Main(string[] args)
13+
{
14+
return new AutoRun(typeof(Program).Assembly).Execute(
15+
args,
16+
new ExtendedTextWrapper(Console.Out),
17+
Console.In);
18+
}
19+
}
20+
}

src/embed_tests/Python.EmbeddingTest.15.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<TargetFrameworks>net40;netcoreapp2.0</TargetFrameworks>
66
<Platforms>x64;x86</Platforms>
77
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
8-
<AssetTargetFallback Condition="'$(TargetFramework)'=='net40' AND $(Configuration.Contains('Mono'))">net45</AssetTargetFallback>
8+
<OutputType Condition="'$(BuildingInsideVisualStudio)' == 'true' OR '$(TargetFramework)' != 'net40'">Exe</OutputType>
9+
<GenerateProgramFile>false</GenerateProgramFile>
910
<AssemblyName>Python.EmbeddingTest</AssemblyName>
1011
<RootNamespace>Python.EmbeddingTest</RootNamespace>
1112
<PackageId>Python.EmbeddingTest</PackageId>
@@ -20,9 +21,8 @@
2021
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
2122
<NoWarn>1591</NoWarn>
2223
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
23-
<PythonBuildDir Condition=" '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
24-
<PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)$(TargetFramework)\</PythonBuildDir>
25-
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)embed_test</PublishDir>
24+
<PythonBuildDir Condition="'$(TargetFramework)'=='net40' AND '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
25+
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)_publish</PublishDir>
2626
<LangVersion>6</LangVersion>
2727
<ErrorReport>prompt</ErrorReport>
2828
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
@@ -91,6 +91,7 @@
9191
<PackageReference Include="NUnit" Version="3.7.1" />
9292
<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
9393
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
94+
<PackageReference Include="NUnitLite" Version="3.7.2" />
9495
</ItemGroup>
9596
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
9697
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />

src/embed_tests/pyimport.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ public void SetUp()
3030
/* Append the tests directory to sys.path
3131
* using reflection to circumvent the private
3232
* modifiers placed on most Runtime methods. */
33+
#if NETCOREAPP2_0
34+
const string s = "../../fixtures";
35+
#else
3336
const string s = "../fixtures";
37+
#endif
38+
Console.WriteLine(TestContext.CurrentContext.TestDirectory);
3439
string testPath = Path.Combine(TestContext.CurrentContext.TestDirectory, s);
3540

3641
IntPtr str = Runtime.Runtime.PyString_FromString(testPath);

src/runtime/Python.Runtime.15.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
2222
<NoWarn>1591;NU1701</NoWarn>
2323
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
24-
<PythonBuildDir Condition=" '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
25-
<PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)$(TargetFramework)\</PythonBuildDir>
26-
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)</PublishDir>
24+
<PythonBuildDir Condition="'$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
25+
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PublishDir>
2726
<LangVersion>6</LangVersion>
2827
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
2928
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>

src/testing/Python.Test.15.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
33
<PropertyGroup>
4-
<TargetFrameworks>net40</TargetFrameworks>
4+
<TargetFrameworks>net40;netcoreapp2.0</TargetFrameworks>
55
<Platforms>x64;x86</Platforms>
66
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
77
<AssemblyName>Python.Test</AssemblyName>
@@ -15,7 +15,7 @@
1515
<NoWarn>1591,0067</NoWarn>
1616
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
1717
<PythonBuildDir Condition=" '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
18-
<PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)$(TargetFramework)\</PythonBuildDir>
18+
<PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PythonBuildDir>
1919
<LangVersion>6</LangVersion>
2020
<SignAssembly>false</SignAssembly>
2121
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>

0 commit comments

Comments
 (0)