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

Revert "cqfd: redirect command stderr to stdout" once again #125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion tests/05-cqfd_init_extra_env
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ else
fi

################################################################################
# restore initial .cqfdrc and Dockerfile
# restore initial Dockerfile
################################################################################
mv -f .cqfd/docker/Dockerfile.orig .cqfd/docker/Dockerfile
4 changes: 4 additions & 0 deletions tests/05-cqfd_run_extra_groups
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ cqfd="$TDIR/.cqfd/cqfd"

cd $TDIR/

cqfdrc_old=$(mktemp)
cp -f .cqfdrc "$cqfdrc_old"

################################################################################
# 'cqfd run' should add extra_groups provided by an environment variable
################################################################################
Expand All @@ -30,3 +33,4 @@ else
jtest_result fail
fi

mv -f "$cqfdrc_old" .cqfdrc
2 changes: 1 addition & 1 deletion tests/05-cqfd_run_extra_hosts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ else
fi

# teardown -- clear the docker_run_args option from config
sed 's/docker_run_args.*//' -i "$TDIR/.cqfdrc"
sed '/\[build\]/{n;d}' -i "$TDIR/.cqfdrc"
2 changes: 1 addition & 1 deletion tests/05-cqfd_run_whitespace_resiliency
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ else
fi

# teardown -- clear the docker_run_args option from config
sed 's/^docker_run_args=.*//' -i "$TDIR/.cqfdrc"
sed '/\[build\]/{n;d}' -i "$TDIR/.cqfdrc"
4 changes: 4 additions & 0 deletions tests/06-cqfd_release
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ cqfd="$TDIR/.cqfd/cqfd"

cd $TDIR/

cqfdrc_old=$(mktemp)
cp -f .cqfdrc "$cqfdrc_old"

################################################################################
# The first invocation has no 'files' parameter defined,
# hence it should fail
Expand Down Expand Up @@ -211,3 +214,4 @@ fi

# cleanup
rm -f tmp.$$ cqfd-$CTEST.tar.xz
mv -f "$cqfdrc_old" .cqfdrc
55 changes: 55 additions & 0 deletions tests/09-cqfd-pts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
#
# validate the allocation of pty and the behavior of redirections

. "$(dirname "$0")/jtest.inc" "$1"
cqfd="$TDIR/.cqfd/cqfd"

cd "$TDIR/"

cqfdrc_old=$(mktemp)
cp -f .cqfdrc "$cqfdrc_old"
sed -i -e "/\[build\]/,/^$/s/^command=.*$/command='tty || true'/" .cqfdrc
$cqfd init

jtest_prepare "cqfd without redirection should allocate a tty"
if $cqfd | grep "/dev/pts/0" ; then
jtest_result pass
else
jtest_result fail
fi

jtest_prepare "cqfd with stdin redirected to /dev/null should not allocate a pty"
if $cqfd </dev/null | grep 'not a tty'; then
jtest_result pass
else
jtest_result fail
fi

jtest_prepare "cqfd with stderr redirected to /dev/null should not allocate a pty"
if $cqfd 2>/dev/null | grep 'not a tty'; then
jtest_result pass
else
jtest_result fail
fi

sed -i -e "/\[build\]/,/^$/s,^command=.*$,command='echo stdout \&\& echo stderr >\&2'," .cqfdrc
$cqfd init

jtest_prepare "cqfd with allocated pty should redirect stdout and stderr to same endpoint"
if $cqfd >out; then
jtest_result pass
else
jtest_result fail
fi
rm out

jtest_prepare "cqfd without allocated pty should redirect stdout and stderr to distinct entpoints"
if $cqfd >out 2>err && grep 'stdout' out && grep 'stderr' err; then
jtest_result pass
else
jtest_result fail
fi
rm out err

mv -f "$cqfdrc_old" .cqfdrc