Skip to content

Commit 7eabb6a

Browse files
committed
TST: Make tests more robust for GHA CI.
Shallow clones and different directory ordering messed things up. They really shouldn't.
1 parent 6f3753e commit 7eabb6a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/test_wrapper.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import glob
44
import os.path
5+
import subprocess
6+
7+
import pytest
58

69
from check_python_h_first.wrapper import (
710
diff_files,
@@ -19,7 +22,11 @@
1922
def test_sort_order():
2023
"""Test that the sort function puts headers first."""
2124
result = sorted(SOURCE_LIST + HEADER_LIST, key=sort_order)
22-
assert result == HEADER_LIST + SOURCE_LIST
25+
# assert result == HEADER_LIST + SOURCE_LIST
26+
result_extensions = [os.path.splitext(name)[1] for name in result]
27+
c_index = result_extensions.index(".c")
28+
assert all(ext == ".h" for ext in result_extensions[:c_index])
29+
assert all(ext == ".c" for ext in result_extensions[c_index:])
2330

2431

2532
def test_find_c_cpp_files():
@@ -40,6 +47,11 @@ def test_process_files():
4047
)
4148

4249

50+
@pytest.mark.xfail(
51+
os.environ.get("GITHUB_ACTIONS", "false") == "true",
52+
reason="GHA does a shallow clone, without the history needed for this test.",
53+
raises=subprocess.CalledProcessError,
54+
)
4355
def test_diff_files():
4456
"""Test whether diff_files picks up the correct files."""
4557
new_files = [os.path.basename(name) for name in diff_files("c8bda44")]

0 commit comments

Comments
 (0)