Skip to content

Commit 147c155

Browse files
Add testing for macOS (#131)
## Description This pull request closes #127 by adding macOS as a tested platform, which should help our clients such as `cibuildwheel` and also aid local testing for contributors on macOS devices. We could skip the integration tests for macOS, but I think we would be fine with keeping them as we would still be under the limit for the number of concurrent jobs on a free GHA plan (eight). I've kept them for now.
1 parent 9398f3f commit 147c155

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

.github/workflows/main.yml

+18-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ env:
1313

1414
jobs:
1515
test:
16-
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, macos-latest]
19+
runs-on: ${{ matrix.os }}
1720
steps:
1821
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1922
with:
@@ -49,7 +52,7 @@ jobs:
4952
- name: Upload coverage
5053
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
5154
with:
52-
name: coverage-no-integration
55+
name: coverage-no-integration-${{ matrix.os }}
5356
path: .coverage
5457
if-no-files-found: error
5558
include-hidden-files: true
@@ -81,12 +84,13 @@ jobs:
8184
fi
8285
8386
integration-test:
84-
runs-on: ubuntu-latest
87+
runs-on: ${{ matrix.os }}
8588
needs: [check-integration-test-trigger]
8689
strategy:
8790
fail-fast: false
8891
matrix:
8992
task: [test-recipe, test-src, test-integration-marker]
93+
os: [ubuntu-latest, macos-latest]
9094
if: needs.check-integration-test-trigger.outputs.run-integration-test
9195
steps:
9296
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -138,7 +142,7 @@ jobs:
138142
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
139143
if: matrix.task == 'test-integration-marker'
140144
with:
141-
name: coverage-from-integration
145+
name: coverage-from-integration-${{ matrix.os }}
142146
path: .coverage
143147
if-no-files-found: error
144148
include-hidden-files: true
@@ -150,9 +154,18 @@ jobs:
150154
steps:
151155
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
152156
with:
157+
path: coverage_files
158+
pattern: coverage-*
153159
merge-multiple: false
154160

161+
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
162+
with:
163+
python-version: "3.12"
164+
165+
- name: Combine coverage files
166+
run: pipx install coverage && coverage combine --append coverage_files/**/.coverage
167+
155168
- uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
156169
with:
157170
fail_ci_if_error: false
158-
files: coverage-no-integration/.coverage,coverage-integration/.coverage
171+
files: .coverage

pyodide_build/tests/recipe/test_bash_runner.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,16 @@ def test_subprocess_with_shared_env_logging(capfd, tmp_path):
5353
dir.mkdir()
5454
p.run("echo 1000", script_name="test script", cwd=dir)
5555
cap = capfd.readouterr()
56-
assert [l.strip() for l in cap.out.splitlines()] == [
57-
"Running test script in",
58-
str(dir),
59-
"1000",
60-
]
56+
57+
# Clean output and compare to expected lines, and join any
58+
# potential split lines to handle platform differences we've
59+
# noticed (across macOS and Linux).
60+
output_lines = [l.strip() for l in cap.out.splitlines()]
61+
cleaned_output = "".join(output_lines)
62+
63+
assert "Running test script in" in cleaned_output
64+
assert str(dir) in cleaned_output
65+
assert "1000" in cleaned_output
6166
assert cap.err == ""
6267

6368
dir = tmp_path / "b"
@@ -66,9 +71,10 @@ def test_subprocess_with_shared_env_logging(capfd, tmp_path):
6671
p.run("exit 7", script_name="test2 script", cwd=dir)
6772
cap = capfd.readouterr()
6873
assert e.value.args[0] == 7
69-
assert [l.strip() for l in cap.out.splitlines()] == [
70-
"Running test2 script in",
71-
str(dir),
72-
]
7374

75+
output_lines = [l.strip() for l in cap.out.splitlines()]
76+
cleaned_output = "".join(output_lines)
77+
78+
assert "Running test2 script in" in cleaned_output
79+
assert str(dir) in cleaned_output
7480
assert "ERROR: test2 script failed" in cap.err

0 commit comments

Comments
 (0)