Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Make assertCapturedSuccess check stderr is empty again #1087

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion test/run-deps
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ testNLTK() {
echo 'ignore::RuntimeWarning' > "${env_dir}/PYTHONWARNINGS"
compile 'nltk' '' "${env_dir}"
assertCaptured "[nltk_data] Downloading package city_database" "STD_ERR"
assertCapturedSuccess
# Can't use `assertCapturedSuccess` since the NLTK downloader outputs all
# progress/status messages to stderr (W-8146040).
assertCapturedSuccessWithStdErr
}

testPsycopg2() {
Expand Down
24 changes: 18 additions & 6 deletions test/run-features
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ testStackChange() {
testSetupPy() {
compile "setup-py"
assertCaptured "maya"
assertCapturedSuccess
# Can't use `assertCapturedSuccess` since stderr contains:
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
assertCapturedSuccessWithStdErr
}

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

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

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

testPipenvVersion2() {
compile "pipenv-version2"
assertCaptured $LATEST_27
assertCapturedSuccess
# Can't use `assertCapturedSuccess` since stderr contains:
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
assertCapturedSuccessWithStdErr
}
testPipenvFullVersion() {
compile "pipenv-full-version"
assertCaptured "3.6.3"
assertCapturedSuccess
# Can't use `assertCapturedSuccess` since stderr contains:
# "cp: cannot stat '/tmp/build_*/requirements.txt': No such file or directory" (W-7924941)
assertCapturedSuccessWithStdErr
}

testNoRequirements() {
Expand Down
8 changes: 6 additions & 2 deletions test/run-versions
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ testPython3_4() {
assertCaptured $LATEST_34
assertNotCaptured "security update"
assertCaptured "Installing pip 19.1.1, setuptools 43.0.0 and wheel 0.33.6"
assertCapturedSuccess
# Can't use `assertCapturedSuccess` since Pip outputs a Python 3.4 EOL warning to stderr,
# and the newest Pip that works on Python 3.4 doesn't support `PIP_NO_PYTHON_VERSION_WARNING`.
assertCapturedSuccessWithStdErr
}

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

testPython3_5() {
Expand Down
29 changes: 21 additions & 8 deletions test/utils
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,20 @@ assertNotCaptured()
assertCapturedSuccess()
{
assertEquals "Captured exit code -" "0" "${RETURN}"
# assertEquals "STD_ERR -" "" "$(cat ${STD_ERR})"
assertEquals "STD_ERR -" "" "$(cat ${STD_ERR})"

if [ $RETURN -ne 0 -a -z "$(cat ${STD_ERR})" ]; then
# Failing exit code but stderr was empty. Display stdout to help debugging.
cat $STD_OUT
echo
if [ $RETURN -ne 0 -o -n "$(cat ${STD_ERR})" ]; then
debug
fi
}

assertCapturedSuccessWithStdErr()
{
assertEquals "Captured exit code -" "0" "${RETURN}"
assertNotEquals "STD_ERR -" "" "$(cat ${STD_ERR})"

if [ ${RETURN} -ne 0 ]; then
debug
fi
}

Expand Down Expand Up @@ -151,9 +159,14 @@ _assertContains()

debug()
{
cat $STD_OUT
echo '^^^^^^'
cat $STD_ERR
echo
echo '### STD_OUT ###'
cat "${STD_OUT}"
echo
echo '### STD_ERR ###'
cat "${STD_ERR}"
echo
echo
}

assertContains()
Expand Down