From 8f443f0fc461bb24a080244cdda33c1e5e438b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Bourbonnais?= Date: Mon, 1 Mar 2021 15:30:58 -0500 Subject: [PATCH 1/6] Re-enable the domain reload tests Add `src/domain_tests` to `testpaths` in pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 9bcf734c6..59b3fb8cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,4 +6,5 @@ build-backend = "setuptools.build_meta" xfail_strict = true testpaths = [ "tests", + "src/domain_tests" ] From 455272f77d1db8923d82967bc3b596fffc5cba07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Bourbonnais?= Date: Mon, 1 Mar 2021 15:51:49 -0500 Subject: [PATCH 2/6] Empty commit to kick the build From 1c4d5e5390c4df7eabc8466675114f71d542d4a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Bourbonnais?= Date: Thu, 4 Mar 2021 11:23:07 -0500 Subject: [PATCH 3/6] Run domain tests only if domains are not supported --- src/domain_tests/conftest.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/domain_tests/conftest.py b/src/domain_tests/conftest.py index 5f0d52e10..38a0115e3 100644 --- a/src/domain_tests/conftest.py +++ b/src/domain_tests/conftest.py @@ -1,7 +1,26 @@ import os -from subprocess import check_call -# test_proj_path = os.path.join(cwd, "..", "testing") -cfd = os.path.dirname(__file__) -bin_path = os.path.join(cfd, 'bin') -check_call(["dotnet", "build", cfd, '-o', bin_path]) \ No newline at end of file +def pytest_addoption(parser): + try: + parser.addoption( + "--runtime", + action="store", + default="default", + help="Must be one of default, netcore, netfx and mono" + ) + except ValueError: + pass # already added + + +collect_ignore = [] + +def pytest_configure(config): + if config.getoption("--runtime") == "netcore": + collect_ignore.append("test_domain_reload.py") + return + + from subprocess import check_call + # test_proj_path = os.path.join(cwd, "..", "testing") + cfd = os.path.dirname(__file__) + bin_path = os.path.join(cfd, 'bin') + check_call(["dotnet", "build", cfd, '-o', bin_path]) From cd03b85fcab8b173429751769e1da5fa02ee4e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Bourbonnais?= Date: Thu, 29 Apr 2021 13:26:22 -0400 Subject: [PATCH 4/6] Move the domain reload tests to the tests directory --- pyproject.toml | 3 +-- pythonnet.sln | 2 +- {src => tests}/domain_tests/App.config | 0 {src => tests}/domain_tests/Python.DomainReloadTests.csproj | 2 +- {src => tests}/domain_tests/TestRunner.cs | 0 {src => tests}/domain_tests/conftest.py | 0 {src => tests}/domain_tests/test_domain_reload.py | 0 7 files changed, 3 insertions(+), 4 deletions(-) rename {src => tests}/domain_tests/App.config (100%) rename {src => tests}/domain_tests/Python.DomainReloadTests.csproj (89%) rename {src => tests}/domain_tests/TestRunner.cs (100%) rename {src => tests}/domain_tests/conftest.py (100%) rename {src => tests}/domain_tests/test_domain_reload.py (100%) diff --git a/pyproject.toml b/pyproject.toml index 59b3fb8cb..b6df82f71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,5 @@ build-backend = "setuptools.build_meta" [tool.pytest.ini_options] xfail_strict = true testpaths = [ - "tests", - "src/domain_tests" + "tests" ] diff --git a/pythonnet.sln b/pythonnet.sln index e02948c18..eca470595 100644 --- a/pythonnet.sln +++ b/pythonnet.sln @@ -12,7 +12,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test", "src\testing\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.PerformanceTests", "src\perf_tests\Python.PerformanceTests.csproj", "{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.DomainReloadTests", "src\domain_tests\Python.DomainReloadTests.csproj", "{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.DomainReloadTests", "tests\domain_tests\Python.DomainReloadTests.csproj", "{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Repo", "Repo", "{441A0123-F4C6-4EE4-9AEE-315FD79BE2D5}" ProjectSection(SolutionItems) = preProject diff --git a/src/domain_tests/App.config b/tests/domain_tests/App.config similarity index 100% rename from src/domain_tests/App.config rename to tests/domain_tests/App.config diff --git a/src/domain_tests/Python.DomainReloadTests.csproj b/tests/domain_tests/Python.DomainReloadTests.csproj similarity index 89% rename from src/domain_tests/Python.DomainReloadTests.csproj rename to tests/domain_tests/Python.DomainReloadTests.csproj index 54196f210..9cb61c6f4 100644 --- a/src/domain_tests/Python.DomainReloadTests.csproj +++ b/tests/domain_tests/Python.DomainReloadTests.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/domain_tests/TestRunner.cs b/tests/domain_tests/TestRunner.cs similarity index 100% rename from src/domain_tests/TestRunner.cs rename to tests/domain_tests/TestRunner.cs diff --git a/src/domain_tests/conftest.py b/tests/domain_tests/conftest.py similarity index 100% rename from src/domain_tests/conftest.py rename to tests/domain_tests/conftest.py diff --git a/src/domain_tests/test_domain_reload.py b/tests/domain_tests/test_domain_reload.py similarity index 100% rename from src/domain_tests/test_domain_reload.py rename to tests/domain_tests/test_domain_reload.py From fcea1282139abe2b5af71488d8e0cc335642d05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Bourbonnais?= Date: Thu, 29 Apr 2021 13:43:33 -0400 Subject: [PATCH 5/6] Merge the conftest.py files --- tests/conftest.py | 11 +++++++++++ tests/domain_tests/conftest.py | 26 -------------------------- 2 files changed, 11 insertions(+), 26 deletions(-) delete mode 100644 tests/domain_tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py index cf3341f01..cd93ced8b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -29,6 +29,8 @@ def pytest_addoption(parser): help="Must be one of default, netcore, netfx and mono" ) +collect_ignore = [] + def pytest_configure(config): global bin_path if "clr" in sys.modules: @@ -73,6 +75,15 @@ def pytest_configure(config): import clr clr.AddReference("Python.Test") + if config.getoption("--runtime") == "netcore": + collect_ignore.append("domain_tests/test_domain_reload.py") + else: + domain_tests_dir = os.path.join(os.path.dirname(__file__), 'domain_tests') + bin_path = os.path.join(domain_tests_dir, 'bin') + check_call(["dotnet", "build", domain_tests_dir, '-o', bin_path]) + + + def pytest_unconfigure(config): global bin_path diff --git a/tests/domain_tests/conftest.py b/tests/domain_tests/conftest.py deleted file mode 100644 index 38a0115e3..000000000 --- a/tests/domain_tests/conftest.py +++ /dev/null @@ -1,26 +0,0 @@ -import os - -def pytest_addoption(parser): - try: - parser.addoption( - "--runtime", - action="store", - default="default", - help="Must be one of default, netcore, netfx and mono" - ) - except ValueError: - pass # already added - - -collect_ignore = [] - -def pytest_configure(config): - if config.getoption("--runtime") == "netcore": - collect_ignore.append("test_domain_reload.py") - return - - from subprocess import check_call - # test_proj_path = os.path.join(cwd, "..", "testing") - cfd = os.path.dirname(__file__) - bin_path = os.path.join(cfd, 'bin') - check_call(["dotnet", "build", cfd, '-o', bin_path]) From d66a290d6cde2cfc857ab945f90f87a25d7074e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Bourbonnais?= Date: Thu, 29 Apr 2021 14:04:55 -0400 Subject: [PATCH 6/6] Don't run domain reload tests in soft mode, increase timeout --- .github/workflows/main.yml | 2 +- tests/conftest.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2dd75c529..38782dfb4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ jobs: build-test: name: Build and Test runs-on: ${{ matrix.os }}-latest - timeout-minutes: 5 + timeout-minutes: 7 strategy: fail-fast: false diff --git a/tests/conftest.py b/tests/conftest.py index cd93ced8b..0361830d6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -75,12 +75,18 @@ def pytest_configure(config): import clr clr.AddReference("Python.Test") - if config.getoption("--runtime") == "netcore": + soft_mode = False + try: + os.environ['PYTHONNET_SHUTDOWN_MODE'] == 'Soft' + except: pass + + if config.getoption("--runtime") == "netcore" or soft_mode\ + : collect_ignore.append("domain_tests/test_domain_reload.py") else: - domain_tests_dir = os.path.join(os.path.dirname(__file__), 'domain_tests') - bin_path = os.path.join(domain_tests_dir, 'bin') - check_call(["dotnet", "build", domain_tests_dir, '-o', bin_path]) + domain_tests_dir = os.path.join(os.path.dirname(__file__), "domain_tests") + bin_path = os.path.join(domain_tests_dir, "bin") + check_call(["dotnet", "build", domain_tests_dir, "-o", bin_path])