Skip to content

Commit 210af92

Browse files
datapythonistaproost
authored andcommitted
CLN: Clean up of CI scripts (pandas-dev#28482)
1 parent 8bf2ae6 commit 210af92

File tree

3 files changed

+33
-45
lines changed

3 files changed

+33
-45
lines changed

ci/azure/posix.yml

+7
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,21 @@ jobs:
6060
echo "Creating Environment"
6161
ci/setup_env.sh
6262
displayName: 'Setup environment and build pandas'
63+
6364
- script: |
6465
source activate pandas-dev
6566
ci/run_tests.sh
6667
displayName: 'Test'
68+
6769
- script: source activate pandas-dev && pushd /tmp && python -c "import pandas; pandas.show_versions();" && popd
70+
displayName: 'Build versions'
71+
6872
- task: PublishTestResults@2
6973
inputs:
7074
testResultsFiles: 'test-data-*.xml'
7175
testRunTitle: ${{ format('{0}-$(CONDA_PY)', parameters.name) }}
76+
displayName: 'Publish test results'
77+
7278
- powershell: |
7379
$junitXml = "test-data-single.xml"
7480
$(Get-Content $junitXml | Out-String) -match 'failures="(.*?)"'
@@ -94,6 +100,7 @@ jobs:
94100
Write-Error "$($matches[1]) tests failed"
95101
}
96102
displayName: 'Check for test failures'
103+
97104
- script: |
98105
source activate pandas-dev
99106
python ci/print_skipped.py

ci/print_skipped.py

+23-35
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,40 @@
11
#!/usr/bin/env python
2-
3-
import math
42
import os
5-
import sys
63
import xml.etree.ElementTree as et
74

85

9-
def parse_results(filename):
6+
def main(filename):
7+
if not os.path.isfile(filename):
8+
return
9+
1010
tree = et.parse(filename)
1111
root = tree.getroot()
12-
skipped = []
13-
1412
current_class = ""
15-
i = 1
16-
assert i - 1 == len(skipped)
1713
for el in root.findall("testcase"):
1814
cn = el.attrib["classname"]
1915
for sk in el.findall("skipped"):
2016
old_class = current_class
2117
current_class = cn
22-
name = "{classname}.{name}".format(
23-
classname=current_class, name=el.attrib["name"]
24-
)
25-
msg = sk.attrib["message"]
26-
out = ""
2718
if old_class != current_class:
28-
ndigits = int(math.log(i, 10) + 1)
29-
30-
# 4 for : + space + # + space
31-
out += "-" * (len(name + msg) + 4 + ndigits) + "\n"
32-
out += "#{i} {name}: {msg}".format(i=i, name=name, msg=msg)
33-
skipped.append(out)
34-
i += 1
35-
assert i - 1 == len(skipped)
36-
assert i - 1 == len(skipped)
37-
# assert len(skipped) == int(root.attrib['skip'])
38-
return "\n".join(skipped)
39-
40-
41-
def main():
42-
test_files = ["test-data-single.xml", "test-data-multiple.xml", "test-data.xml"]
43-
44-
print("SKIPPED TESTS:")
45-
for fn in test_files:
46-
if os.path.isfile(fn):
47-
print(parse_results(fn))
48-
return 0
19+
yield None
20+
yield {
21+
"class_name": current_class,
22+
"test_name": el.attrib["name"],
23+
"message": sk.attrib["message"],
24+
}
4925

5026

5127
if __name__ == "__main__":
52-
sys.exit(main())
28+
print("SKIPPED TESTS:")
29+
i = 1
30+
for file_type in ("-single", "-multiple", ""):
31+
for test_data in main("test-data{}.xml".format(file_type)):
32+
if test_data is None:
33+
print("-" * 80)
34+
else:
35+
print(
36+
"#{i} {class_name}.{test_name}: {message}".format(
37+
**dict(test_data, i=i)
38+
)
39+
)
40+
i += 1

ci/run_tests.sh

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
#!/bin/bash
1+
#!/bin/bash -e
22

3-
set -e
4-
5-
if [ "$DOC" ]; then
6-
echo "We are not running pytest as this is a doc-build"
7-
exit 0
8-
fi
9-
10-
# Workaround for pytest-xdist flaky collection order
3+
# Workaround for pytest-xdist (it collects different tests in the workers if PYTHONHASHSEED is not set)
114
# https://github.com/pytest-dev/pytest/issues/920
125
# https://github.com/pytest-dev/pytest/issues/1075
136
export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))')
@@ -16,7 +9,7 @@ if [ -n "$LOCALE_OVERRIDE" ]; then
169
export LC_ALL="$LOCALE_OVERRIDE"
1710
export LANG="$LOCALE_OVERRIDE"
1811
PANDAS_LOCALE=`python -c 'import pandas; pandas.get_option("display.encoding")'`
19-
if [[ "$LOCALE_OVERIDE" != "$PANDAS_LOCALE" ]]; then
12+
if [[ "$LOCALE_OVERRIDE" != "$PANDAS_LOCALE" ]]; then
2013
echo "pandas could not detect the locale. System locale: $LOCALE_OVERRIDE, pandas detected: $PANDAS_LOCALE"
2114
# TODO Not really aborting the tests until https://github.com/pandas-dev/pandas/issues/23923 is fixed
2215
# exit 1

0 commit comments

Comments
 (0)