summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2022-02-16 13:19:53 +0100
committerStefan Behnel <stefan_ml@behnel.de>2022-02-16 13:19:53 +0100
commitf61e759dcc2fb5ab3e9398a43468d44b7a9a6818 (patch)
tree8e7f117f9f22500b39ba82053664765a7d35d3af
parent5ba24b45a3e4d5b49c0fb9590c3e36d12c54d174 (diff)
downloadcython-f61e759dcc2fb5ab3e9398a43468d44b7a9a6818.tar.gz
Fix depfile tests on Windows.
-rw-r--r--tests/build/depfile.srctree6
-rw-r--r--tests/build/depfile_numpy.srctree25
-rw-r--r--tests/build/depfile_package.srctree13
3 files changed, 25 insertions, 19 deletions
diff --git a/tests/build/depfile.srctree b/tests/build/depfile.srctree
index 0c2194f75..1a9df6b00 100644
--- a/tests/build/depfile.srctree
+++ b/tests/build/depfile.srctree
@@ -1,5 +1,7 @@
+"""
PYTHON -m Cython.Build.Cythonize -M foo.pyx
PYTHON check.py
+"""
######## foo.pyx ########
@@ -25,9 +27,7 @@ cdef inline void empty():
######## check.py ########
-import os
-
with open("foo.c.dep", "r") as f:
- contents = f.read().replace("\n", " ").replace("\\", "")
+ contents = f.read().replace("\\\n", " ").replace("\n", " ")
assert sorted(contents.split()) == ['bar.pxd', 'baz.pxi', 'foo.c:', 'foo.pyx'], contents
diff --git a/tests/build/depfile_numpy.srctree b/tests/build/depfile_numpy.srctree
index 4a2461c64..3e2164ba9 100644
--- a/tests/build/depfile_numpy.srctree
+++ b/tests/build/depfile_numpy.srctree
@@ -1,7 +1,9 @@
# tag: numpy
+"""
PYTHON -m Cython.Build.Cythonize -M dep_np.pyx
PYTHON check_np.py
+"""
######## dep_np.pyx ########
@@ -12,14 +14,13 @@ np.import_array()
######## check_np.py ########
-import os
-import re
+import os.path
import numpy as np
import Cython
with open("dep_np.c.dep", "r") as f:
- contents = f.read().replace("\n", " ").replace("\\", "")
+ contents = f.read().replace('\\\n', ' ').replace('\n', ' ')
contents = contents.split()
@@ -29,7 +30,11 @@ contents = [fname.replace(cy_prefix, "cy_prefix") for fname in contents]
np_prefix, _ = os.path.split(np.__file__)
contents = [fname.replace(np_prefix, "np_prefix") for fname in contents]
-expected = ['cy_prefix/Includes/cpython/buffer.pxd',
+contents = [path.split(os.sep) for path in contents]
+contents.sort()
+
+expected = [path.split('/') for path in [
+ 'cy_prefix/Includes/cpython/buffer.pxd',
'cy_prefix/Includes/cpython/mem.pxd',
'cy_prefix/Includes/cpython/object.pxd',
'cy_prefix/Includes/cpython/ref.pxd',
@@ -37,13 +42,15 @@ expected = ['cy_prefix/Includes/cpython/buffer.pxd',
'cy_prefix/Includes/libc/stdio.pxd',
'cy_prefix/Includes/libc/string.pxd',
'dep_np.c:',
- 'dep_np.pyx',]
+ 'dep_np.pyx',
+]]
# Also account for legacy numpy versions, which do not ship
# `__init__.pxd` hence the fallback is used:
-if 'cy_prefix/Includes/numpy/__init__.pxd' in contents:
- expected.append('cy_prefix/Includes/numpy/__init__.pxd')
+if ['cy_prefix', 'Includes', 'numpy', '__init__.pxd'] in contents:
+ expected.append(['cy_prefix', 'Includes', 'numpy', '__init__.pxd'])
else:
- expected.append('np_prefix/__init__.pxd')
+ expected.append(['np_prefix', '__init__.pxd'])
-assert sorted(contents) == sorted(expected), sorted(contents)
+expected.sort()
+assert contents == expected, contents
diff --git a/tests/build/depfile_package.srctree b/tests/build/depfile_package.srctree
index 54dcad9f1..8e0916ca5 100644
--- a/tests/build/depfile_package.srctree
+++ b/tests/build/depfile_package.srctree
@@ -1,16 +1,16 @@
-'''
+"""
PYTHON -m Cython.Build.Cythonize -i pkg --depfile
PYTHON package_test.py
-'''
+"""
######## package_test.py ########
-import os
+import os.path
with open("pkg/test.c.dep", "r") as f:
- contents = f.read().replace("\n", " ").replace("\\", "")
+ contents = f.read().replace("\\\n", " ").replace("\\\n", " ")
-assert sorted(contents.split()) == sorted(['test.c:', 'sub/incl.pxi', 'test.pxd', 'test.pyx']), contents
+assert sorted(contents.split()) == sorted(['test.c:', os.path.join('sub', 'incl.pxi'), 'test.pxd', 'test.pyx']), contents
with open("pkg/sub/test.c.dep", "r") as f:
@@ -18,7 +18,7 @@ with open("pkg/sub/test.c.dep", "r") as f:
contents = [os.path.relpath(entry, '.')
if os.path.isabs(entry) else entry for entry in contents.split()]
-assert sorted(contents) == sorted(['test.c:', 'incl.pxi', 'test.pyx', '../test.pxd']), contents
+assert sorted(contents) == sorted(['test.c:', 'incl.pxi', 'test.pyx', os.path.join('..', 'test.pxd')]), contents
######## pkg/__init__.py ########
@@ -55,4 +55,3 @@ TEST = 'pkg.sub.test'
######## pkg/sub/incl.pxi ########
pass
-