Skip to content

Commit ff8945c

Browse files
authored
Tests: Make assertCapturedSuccess check stderr is empty again (#1087)
`assertCapturedSuccess` used to check that `stderr` was empty, until: 797652a#diff-65c067a6f0a3aef292fb54ec21a1fe8cR98 Adding back the assertion exposes some new bugs, which I'll fix in later PRs. In the meantime affected tests have been adjusted to use a new `assertCapturedSuccessWithStdErr`. The test harness output for the failing case has also been improved, to ease debugging. Closes @W-7918492@. [skip changelog]
1 parent 4e78b5d commit ff8945c

File tree

4 files changed

+48
-17
lines changed

4 files changed

+48
-17
lines changed

test/run-deps

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ testNLTK() {
4343
echo 'ignore::RuntimeWarning' > "${env_dir}/PYTHONWARNINGS"
4444
compile 'nltk' '' "${env_dir}"
4545
assertCaptured "[nltk_data] Downloading package city_database" "STD_ERR"
46-
assertCapturedSuccess
46+
# Can't use `assertCapturedSuccess` since the NLTK downloader outputs all
47+
# progress/status messages to stderr (W-8146040).
48+
assertCapturedSuccessWithStdErr
4749
}
4850

4951
testPsycopg2() {

test/run-features

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ testStackChange() {
3333
testSetupPy() {
3434
compile "setup-py"
3535
assertCaptured "maya"
36-
assertCapturedSuccess
36+
# Can't use `assertCapturedSuccess` since stderr contains:
37+
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
38+
assertCapturedSuccessWithStdErr
3739
}
3840

3941
testStandardRequirements() {
@@ -45,29 +47,39 @@ testStandardRequirements() {
4547
testPipenv() {
4648
compile "pipenv"
4749
assertCaptured "Installing pip 9.0.2, setuptools 47.1.1 and wheel 0.34.2"
48-
assertCapturedSuccess
50+
# Can't use `assertCapturedSuccess` since stderr contains:
51+
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
52+
assertCapturedSuccessWithStdErr
4953
}
5054

5155
testPipenvLock() {
5256
compile "pipenv-lock"
53-
assertCapturedSuccess
57+
# Can't use `assertCapturedSuccess` since stderr contains:
58+
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
59+
assertCapturedSuccessWithStdErr
5460
}
5561

5662
testPipenvVersion() {
5763
compile "pipenv-version"
5864
assertCaptured $DEFAULT_PYTHON_VERSION
59-
assertCapturedSuccess
65+
# Can't use `assertCapturedSuccess` since stderr contains:
66+
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
67+
assertCapturedSuccessWithStdErr
6068
}
6169

6270
testPipenvVersion2() {
6371
compile "pipenv-version2"
6472
assertCaptured $LATEST_27
65-
assertCapturedSuccess
73+
# Can't use `assertCapturedSuccess` since stderr contains:
74+
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
75+
assertCapturedSuccessWithStdErr
6676
}
6777
testPipenvFullVersion() {
6878
compile "pipenv-full-version"
6979
assertCaptured "3.6.3"
70-
assertCapturedSuccess
80+
# Can't use `assertCapturedSuccess` since stderr contains:
81+
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
82+
assertCapturedSuccessWithStdErr
7183
}
7284

7385
testNoRequirements() {

test/run-versions

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ testPython3_4() {
4040
assertCaptured $LATEST_34
4141
assertNotCaptured "security update"
4242
assertCaptured "Installing pip 19.1.1, setuptools 43.0.0 and wheel 0.33.6"
43-
assertCapturedSuccess
43+
# Can't use `assertCapturedSuccess` since Pip outputs a Python 3.4 EOL warning to stderr,
44+
# and the newest Pip that works on Python 3.4 doesn't support `PIP_NO_PYTHON_VERSION_WARNING`.
45+
assertCapturedSuccessWithStdErr
4446
}
4547

4648
testPython3_4_warn() {
4749
compile "python3_4_warn"
4850
assertCaptured "python-3.4.9"
4951
assertCaptured "security update!"
50-
assertCapturedSuccess
52+
# Can't use `assertCapturedSuccess` since Pip outputs a Python 3.4 EOL warning to stderr,
53+
# and the newest Pip that works on Python 3.4 doesn't support `PIP_NO_PYTHON_VERSION_WARNING`.
54+
assertCapturedSuccessWithStdErr
5155
}
5256

5357
testPython3_5() {

test/utils

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,20 @@ assertNotCaptured()
8585
assertCapturedSuccess()
8686
{
8787
assertEquals "Captured exit code -" "0" "${RETURN}"
88-
# assertEquals "STD_ERR -" "" "$(cat ${STD_ERR})"
88+
assertEquals "STD_ERR -" "" "$(cat ${STD_ERR})"
8989

90-
if [ $RETURN -ne 0 -a -z "$(cat ${STD_ERR})" ]; then
91-
# Failing exit code but stderr was empty. Display stdout to help debugging.
92-
cat $STD_OUT
93-
echo
90+
if [ $RETURN -ne 0 -o -n "$(cat ${STD_ERR})" ]; then
91+
debug
92+
fi
93+
}
94+
95+
assertCapturedSuccessWithStdErr()
96+
{
97+
assertEquals "Captured exit code -" "0" "${RETURN}"
98+
assertNotEquals "STD_ERR -" "" "$(cat ${STD_ERR})"
99+
100+
if [ ${RETURN} -ne 0 ]; then
101+
debug
94102
fi
95103
}
96104

@@ -151,9 +159,14 @@ _assertContains()
151159

152160
debug()
153161
{
154-
cat $STD_OUT
155-
echo '^^^^^^'
156-
cat $STD_ERR
162+
echo
163+
echo '### STD_OUT ###'
164+
cat "${STD_OUT}"
165+
echo
166+
echo '### STD_ERR ###'
167+
cat "${STD_ERR}"
168+
echo
169+
echo
157170
}
158171

159172
assertContains()

0 commit comments

Comments
 (0)