Skip to content

Commit d92460b

Browse files
author
Eric Snow
authored
Make sure filenames are not norm-cased on Windows. (microsoft#6856)
(for microsoft#6758)
1 parent 86d669e commit d92460b

9 files changed

Lines changed: 64 additions & 10 deletions

File tree

build/ci/templates/test_phases.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ steps:
231231
# > python -m pip install -U -r build/test-requirements.txt
232232
# > python pythonFiles/tests/run_all.py --color=yes --junit-xml=python-tests-junit.xml
233233
- bash: |
234-
python pythonFiles/tests/run_all.py --color=yes --junit-xml=$COMMON_TESTRESULTSDIRECTORY/python-tests-junit.xml
234+
python pythonFiles/tests/run_all.py --color=no --junit-xml=$COMMON_TESTRESULTSDIRECTORY/python-tests-junit.xml
235235
displayName: 'Python unittests'
236236
condition: and(succeeded(), contains(variables['TestsToRun'], 'pythonUnitTests'))
237237
@@ -256,7 +256,7 @@ steps:
256256
# > python -m pip install -U -r build/test-requirements.txt
257257
# > python pythonFiles/tests/run_all.py --color=yes --junit-xml=python-tests-junit.xml
258258
- bash: |
259-
python -m IPython pythonFiles/tests/run_all.py -- --color=yes --junit-xml=$COMMON_TESTRESULTSDIRECTORY/ipython-tests-junit.xml
259+
python -m IPython pythonFiles/tests/run_all.py -- --color=no --junit-xml=$COMMON_TESTRESULTSDIRECTORY/ipython-tests-junit.xml
260260
displayName: 'Python ipython tests'
261261
condition: and(succeeded(), contains(variables['TestsToRun'], 'pythonIPythonTests'))
262262

pythonFiles/testing_tools/adapter/pytest/_pytest_item.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ def _get_location(item, testroot, relfile, _normcase, _pathsep):
270270

271271
def _matches_relfile(srcfile, testroot, relfile, _normcase, _pathsep):
272272
"""Return True if "srcfile" matches the given relfile."""
273+
testroot = _normcase(testroot)
273274
srcfile = _normcase(srcfile)
274275
relfile = _normcase(relfile)
275276
if srcfile == relfile:

pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/__init__.py

Whitespace-only changes.

pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/b/C/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
def test_okay():
3+
assert True

pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/A/b/__init__.py

Whitespace-only changes.

pythonFiles/tests/testing_tools/adapter/.data/NormCase/tests/__init__.py

Whitespace-only changes.

pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,14 +787,14 @@ def test_windows(self):
787787
stub = Stub()
788788
discovered = StubDiscoveredTests(stub)
789789
session = StubPytestSession(stub)
790-
testroot = r'c:\a\b\c'
790+
testroot = r'C:\A\B\C'
791791
relfile = r'X\Y\Z\test_eggs.py'
792792
session.items = [
793793
StubFunctionItem(
794794
stub,
795-
nodeid='X/Y/Z/test_eggs.py::SpamTests::test_spam',
795+
nodeid='x/y/z/test_eggs.py::SpamTests::test_spam',
796796
name='test_spam',
797-
location=('x/y/z/test_eggs.py', 12, 'SpamTests.test_spam'),
797+
location=('X/Y/Z/test_eggs.py', 12, 'SpamTests.test_spam'),
798798
fspath=testroot + '\\' + relfile,
799799
function=FakeFunc('test_spam'),
800800
),
@@ -825,12 +825,12 @@ def normcase(path):
825825
id=r'.\x\y\z\test_eggs.py::SpamTests::test_spam',
826826
name='test_spam',
827827
path=TestPath(
828-
root=testroot,
829-
relfile=r'.\X\Y\Z\test_eggs.py',
828+
root=testroot, # not normalized
829+
relfile=r'.\X\Y\Z\test_eggs.py', # not normalized
830830
func='SpamTests.test_spam',
831831
sub=None,
832832
),
833-
source=r'.\X\Y\Z\test_eggs.py:{}'.format(13),
833+
source=r'.\X\Y\Z\test_eggs.py:{}'.format(13), # not normalized
834834
markers=None,
835835
parentid=r'.\x\y\z\test_eggs.py::SpamTests',
836836
),

pythonFiles/tests/testing_tools/adapter/test_functional.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222

2323
def resolve_testroot(name):
24-
projroot = os.path.normcase(
25-
os.path.join(DATA_DIR, name))
24+
projroot = os.path.join(DATA_DIR, name)
2625
return projroot, os.path.join(projroot, 'tests')
2726

2827

@@ -256,6 +255,57 @@ def test_discover_syntax_error(self):
256255
)
257256
self.assertIn('(exit code 2)', cm.exception.output)
258257

258+
def test_discover_normcase(self):
259+
projroot, testroot = resolve_testroot('NormCase')
260+
261+
out = run_adapter('discover', 'pytest',
262+
'--rootdir', projroot,
263+
testroot)
264+
result = json.loads(out)
265+
266+
self.maxDiff = None
267+
self.assertTrue(projroot.endswith('NormCase'))
268+
fix_id = os.path.normcase
269+
self.assertEqual(result, [{
270+
'root': projroot,
271+
'rootid': '.',
272+
'parents': [
273+
{'id': fix_id('./tests'),
274+
'kind': 'folder',
275+
'name': 'tests',
276+
'parentid': '.',
277+
},
278+
{'id': fix_id('./tests/A'),
279+
'kind': 'folder',
280+
'name': fix_id('A'),
281+
'parentid': fix_id('./tests'),
282+
},
283+
{'id': fix_id('./tests/A/b'),
284+
'kind': 'folder',
285+
'name': 'b',
286+
'parentid': fix_id('./tests/A'),
287+
},
288+
{'id': fix_id('./tests/A/b/C'),
289+
'kind': 'folder',
290+
'name': fix_id('C'),
291+
'parentid': fix_id('./tests/A/b'),
292+
},
293+
{'id': fix_id('./tests/A/b/C/test_Spam.py'),
294+
'kind': 'file',
295+
'name': fix_id('test_Spam.py'),
296+
'parentid': fix_id('./tests/A/b/C'),
297+
},
298+
],
299+
'tests': [
300+
{'id': fix_id('./tests/A/b/C/test_Spam.py::test_okay'),
301+
'name': 'test_okay',
302+
'source': fix_path('./tests/A/b/C/test_Spam.py:2'),
303+
'markers': [],
304+
'parentid': fix_id('./tests/A/b/C/test_Spam.py'),
305+
},
306+
],
307+
}])
308+
259309

260310
COMPLEX = {
261311
'root': None,

0 commit comments

Comments
 (0)