Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit dee134c

Browse files
committed
Add coverage
1 parent 5cdc0b4 commit dee134c

File tree

5 files changed

+60
-11
lines changed

5 files changed

+60
-11
lines changed

.travis.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,20 @@ addons:
2525
- nunit-console
2626

2727
install:
28-
- pip install six
29-
- pip install pycparser
30-
- python setup.py build_ext --inplace
28+
- pip install pycparser coverage codecov six
29+
- coverage run setup.py build_ext --inplace
3130

3231
script:
3332
- export PYTHONPATH=`pwd`:$PYTHONPATH
3433
- python src/tests/runtests.py
3534
# - nunit-console src/embed_tests/bin/x64/ReleaseMono/Python.EmbeddingTest.dll
3635

36+
after_success:
37+
# Uncomment if need to geninterop, ie. py37 final
38+
# - python tools/geninterop/geninterop.py
39+
40+
# Waiting on mono-cov support or SharpCover
41+
- codecov
42+
3743
notifications:
3844
email: false

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![appveyor shield][]](https://ci.appveyor.com/project/pythonnet/pythonnet/branch/master)
44
[![travis shield][]](https://travis-ci.org/pythonnet/pythonnet)
5+
[![codecov shield][]](https://codecov.io/github/pythonnet/pythonnet)
56
[![license shield][]](./LICENSE)
67
[![pypi package version][]](https://pypi.python.org/pypi/pythonnet)
78
[![python supported shield][]](https://pypi.python.org/pypi/pythonnet)
@@ -80,6 +81,8 @@ int32
8081

8182
[appveyor shield]: https://img.shields.io/appveyor/ci/pythonnet/pythonnet/master.svg?label=AppVeyor
8283

84+
[codecov shield]: https://img.shields.io/codecov/c/github/pythonnet/pythonnet/pytest.svg?label=codecov
85+
8386
[license shield]: https://img.shields.io/badge/license-MIT-blue.svg
8487

8588
[pypi package version]: https://img.shields.io/pypi/v/pythonnet.svg

appveyor.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ environment:
1010
PYTHONUNBUFFERED: True
1111
PYTHONWARNINGS: 'ignore:::wheel.pep425tags:'
1212
PYTHONPATH: C:\testdir
13-
NUNIT: nunit-console
1413
CONDA_BLD: C:\conda
1514
CONDA_BLD_VERSION: 3.5
1615

@@ -35,7 +34,6 @@ init:
3534
- set CONDA_BLD_ARCH=%PLATFORM:x=%
3635
- set PYTHON=C:\PYTHON%PYTHON_VERSION:.=%
3736
- if %PLATFORM%==x86 (set CONDA_BLD_ARCH=32)
38-
- if %PLATFORM%==x86 (set NUNIT=%NUNIT%-x86)
3937
- if %PLATFORM%==x64 (set PYTHON=%PYTHON%-x64)
4038

4139
# Prepend newly installed Python to the PATH of this build
@@ -47,21 +45,29 @@ init:
4745
- python -c "import ctypes; print(ctypes.sizeof(ctypes.c_wchar))"
4846

4947
install:
50-
# install for wheels
51-
- pip install --upgrade pip wheel six
48+
# install for wheels & coverage
49+
- pip install --upgrade pip wheel coverage codecov six
50+
51+
# Install OpenCover. Can't put on packages.config; not Linux/Mono compatible
52+
- .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages
5253

5354
build_script:
54-
# build clean sdist & wheel
55-
- python setup.py sdist bdist_wheel
55+
# build clean sdist & wheel with coverage of setup.py, install local wheel
56+
- coverage run setup.py sdist bdist_wheel
5657

5758
test_script:
5859
- pip install --no-index --find-links=.\dist\ pythonnet
5960
- ps: Copy-Item (Resolve-Path .\build\*\Python.Test.dll) C:\testdir
60-
- python src\tests\runtests.py
61-
# - "%NUNIT% src/embed_tests/bin/%PLATFORM%/ReleaseWin/Python.EmbeddingTest.dll"
61+
62+
# Test runner
63+
- ps: .\ci\appveyor_run_tests.ps1
6264

6365
# Build conda-recipe on Pull Requests
6466
- ps: .\ci\appveyor_build_recipe.ps1
6567

68+
on_finish:
69+
# Upload coverage
70+
- codecov
71+
6672
artifacts:
6773
- path: dist\*

ci/appveyor_run_tests.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Script to simplify appveyor configuration and resolve path to tools
2+
3+
# Executable paths for OpenCover
4+
# Note if OpenCover fails, it won't affect the exit codes.
5+
$OPENCOVER = Resolve-Path .\packages\OpenCover.*\tools\OpenCover.Console.exe
6+
$NUNIT = Resolve-Path .\packages\NUnit.ConsoleRunner*\tools\nunit3-console.exe
7+
$PY = Get-Command python
8+
9+
# Can't use ".\build\*\Python.EmbeddingTest.dll". Missing framework files.
10+
$CS_TESTS = Resolve-Path .\src\embed_tests\bin\*\*\Python.EmbeddingTest.dll
11+
$RUNTIME_DIR = Resolve-Path .\src\runtime\bin\*\ReleaseWin\
12+
13+
# Run python tests with C# coverage
14+
# why `2>&1 | %{ "$_" }`? see: http://stackoverflow.com/a/20950421/5208670
15+
.$OPENCOVER -register:user -searchdirs:"$RUNTIME_DIR" -output:py.coverage -target:"$PY" -targetargs:src\tests\runtests.py -returntargetcode 2>&1 | %{ "$_" }
16+
$PYTHON_STATUS = $LastExitCode
17+
if ($PYTHON_STATUS -ne 0) {
18+
Write-Host "Python tests failed, continuing to embedded tests" -ForegroundColor "Red"
19+
}
20+
21+
# Run Embedded tests with C# coverage
22+
# .$OPENCOVER -register:user -searchdirs:"$RUNTIME_DIR" -output:cs.coverage -target:"$NUNIT" -targetargs:"$CS_TESTS" -returntargetcode
23+
# $NUNIT_STATUS = $LastExitCode
24+
# if ($NUNIT_STATUS -ne 0) {
25+
# Write-Host "Embedded tests failed" -ForegroundColor "Red"
26+
# }
27+
28+
# Embedded tests failing due to open issues, pass/fail only on Python exit code
29+
# if ($PYTHON_STATUS -ne 0 -or $NUNIT_STATUS -ne 0) {
30+
if ($PYTHON_STATUS -ne 0) {
31+
Write-Host "Tests failed" -ForegroundColor "Red"
32+
$host.SetShouldExit(1)
33+
}

src/embed_tests/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="NUnit" version="3.5.0" targetFramework="net40" />
4+
<package id="NUnit.ConsoleRunner" version="3.5.0" targetFramework="net40" />
45
</packages>

0 commit comments

Comments
 (0)