Skip to content

Commit 57c47fa

Browse files
committed
test: add windows integration test
1 parent 496bb0f commit 57c47fa

5 files changed

Lines changed: 80 additions & 25 deletions

File tree

.github/workflows/python_tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ jobs:
1414
fail-fast: false
1515
max-parallel: 5
1616
matrix:
17-
os: [macos-15-intel, macos-latest, ubuntu-latest] # , windows-latest]
17+
os: [macos-15-intel, macos-latest, ubuntu-latest, windows-latest]
1818
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1919
include:
2020
- os: macos-26
2121
python-version: 3.x
22+
- os: ubuntu-24.04-arm # Ubuntu on ARM
23+
python-version: "3.14"
24+
- os: windows-11-arm # Windows on ARM
25+
python-version: "3.14"
2226
steps:
2327
- uses: actions/checkout@v6
2428
- name: Set up Python ${{ matrix.python-version }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,7 @@ static
144144

145145
test/fixtures/out
146146
*.actual
147+
*.sln
148+
*.vcproj
149+
!test/fixtures/expected-win32/**/*.sln
150+
!test/fixtures/expected-win32/**/*.vcproj
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Microsoft Visual Studio Solution File, Format Version 9.00
2+
# Visual Studio 2005
3+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{D93A5F33-D56E-04D4-E3C2-73BC9FA01802}"
4+
EndProject
5+
Global
6+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7+
Default|Win32 = Default|Win32
8+
EndGlobalSection
9+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
10+
{D93A5F33-D56E-04D4-E3C2-73BC9FA01802}.Default|Win32.ActiveCfg = Default|Win32
11+
{D93A5F33-D56E-04D4-E3C2-73BC9FA01802}.Default|Win32.Build.0 = Default|Win32
12+
EndGlobalSection
13+
GlobalSection(SolutionProperties) = preSolution
14+
HideSolutionNode = FALSE
15+
EndGlobalSection
16+
EndGlobal
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="Windows-1252"?><VisualStudioProject Keyword="Win32Proj" Name="test" ProjectGUID="{D93A5F33-D56E-04D4-E3C2-73BC9FA01802}" ProjectType="Visual C++" RootNamespace="test" Version="8.00"><Platforms><Platform Name="Win32"/></Platforms><ToolFiles/><Configurations><Configuration ConfigurationType="1" IntermediateDirectory="$(ConfigurationName)\obj\$(ProjectName)\" Name="Default|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)\"><Tool AdditionalDependencies="$(NOINHERIT)" AdditionalLibraryDirectories="mylib" Name="VCLinkerTool" OutputFile="$(OutDir)\$(ProjectName).exe"/><Tool AdditionalIncludeDirectories="include" Name="VCCLCompilerTool" ProgramDataBaseFileName="$(IntDir)$(ProjectName)\vc80.pdb"/><Tool AdditionalIncludeDirectories="include" Name="VCResourceCompilerTool"/></Configuration></Configurations><References/><Files><File RelativePath="test.cc"/><File RelativePath="integration.gyp"/></Files><Globals/></VisualStudioProject>

test/integration_test.py

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,53 @@
55
import os
66
import re
77
import shutil
8+
import sys
89
import unittest
910

1011
import gyp
1112

1213
fixture_dir = os.path.join(os.path.dirname(__file__), "fixtures")
1314
gyp_file = os.path.join(os.path.dirname(__file__), "fixtures/integration.gyp")
1415

15-
supported_sysnames = {"darwin", "linux"}
16-
sysname = os.uname().sysname.lower()
16+
if sys.platform == "win32":
17+
sysname = sys.platform
18+
else:
19+
sysname = os.uname().sysname.lower()
1720
expected_dir = os.path.join(fixture_dir, f"expected-{sysname}")
1821

1922

20-
class TestGyp(unittest.TestCase):
21-
def setUp(self) -> None:
22-
if sysname not in supported_sysnames:
23-
self.skipTest(f"Unsupported system: {sysname}")
24-
shutil.rmtree(os.path.join(fixture_dir, "out"), ignore_errors=True)
23+
def assert_file(test, actual, expected) -> None:
24+
actual_filepath = os.path.join(fixture_dir, actual)
25+
expected_filepath = os.path.join(expected_dir, expected)
2526

26-
def assert_file(self, actual, expected) -> None:
27-
actual_filepath = os.path.join(fixture_dir, actual)
28-
expected_filepath = os.path.join(expected_dir, expected)
27+
with open(expected_filepath) as in_file:
28+
expected_bytes = re.escape(in_file.read())
29+
expected_bytes = expected_bytes.replace("\\*", ".*")
30+
expected_re = re.compile(expected_bytes)
2931

30-
with open(expected_filepath) as in_file:
31-
expected_bytes = re.escape(in_file.read())
32-
expected_bytes = expected_bytes.replace("\\*", ".*")
33-
expected_re = re.compile(expected_bytes)
32+
with open(actual_filepath) as in_file:
33+
actual_bytes = in_file.read()
3434

35-
with open(actual_filepath) as in_file:
36-
actual_bytes = in_file.read()
35+
try:
36+
test.assertRegex(actual_bytes, expected_re)
37+
except Exception:
38+
shutil.copyfile(actual_filepath, f"{expected_filepath}.actual")
39+
raise
3740

38-
try:
39-
self.assertRegex(actual_bytes, expected_re)
40-
except Exception:
41-
shutil.copyfile(actual_filepath, f"{expected_filepath}.actual")
42-
raise
41+
42+
class TestGypUnix(unittest.TestCase):
43+
supported_sysnames = {"darwin", "linux"}
44+
45+
def setUp(self) -> None:
46+
if sysname not in TestGypUnix.supported_sysnames:
47+
self.skipTest(f"Unsupported system: {sysname}")
48+
shutil.rmtree(os.path.join(fixture_dir, "out"), ignore_errors=True)
4349

4450
def test_ninja(self) -> None:
4551
rc = gyp.main(["-f", "ninja", "--depth", fixture_dir, gyp_file])
4652
assert rc == 0
4753

48-
self.assert_file("out/Default/obj/test.ninja", "ninja/test.ninja")
54+
assert_file(self, "out/Default/obj/test.ninja", "ninja/test.ninja")
4955

5056
def test_make(self) -> None:
5157
rc = gyp.main(
@@ -61,10 +67,34 @@ def test_make(self) -> None:
6167
)
6268
assert rc == 0
6369

64-
self.assert_file("out/test.target.mk", "make/test.target.mk")
70+
assert_file(self, "out/test.target.mk", "make/test.target.mk")
6571

6672
def test_cmake(self) -> None:
6773
rc = gyp.main(["-f", "cmake", "--depth", fixture_dir, gyp_file])
6874
assert rc == 0
6975

70-
self.assert_file("out/Default/CMakeLists.txt", "cmake/CMakeLists.txt")
76+
assert_file(self, "out/Default/CMakeLists.txt", "cmake/CMakeLists.txt")
77+
78+
79+
class TestGypWindows(unittest.TestCase):
80+
def setUp(self) -> None:
81+
if sys.platform != "win32":
82+
self.skipTest("Windows-only test")
83+
shutil.rmtree(os.path.join(fixture_dir, "out"), ignore_errors=True)
84+
85+
def test_msvs(self) -> None:
86+
rc = gyp.main(
87+
[
88+
"-f",
89+
"msvs",
90+
"--depth",
91+
fixture_dir,
92+
"--generator-output",
93+
"out",
94+
gyp_file
95+
]
96+
)
97+
assert rc == 0
98+
99+
assert_file(self, "test.vcproj", "msvs/test.vcproj")
100+
assert_file(self, "integration.sln", "msvs/integration.sln")

0 commit comments

Comments
 (0)