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

stdstream support #168

Merged
merged 9 commits into from
Sep 18, 2024
Merged
Changes from 1 commit
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
20 changes: 14 additions & 6 deletions test/stdstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ TRY="$TRY_TOP/try"

cmdfile="$(mktemp)"

cat > "$cmdfile" <<EOF
file /dev/stdin
file /dev/stdout
file /dev/stderr
cat > "$cmdfile" <<'EOF'
read x < /dev/stdin
ezrizhu marked this conversation as resolved.
Show resolved Hide resolved
echo $((x * 2)) > /dev/stdout
echo $((x * 3)) > /dev/stderr

EOF

chmod +x "$cmdfile"

result=$("$TRY" "$cmdfile")
expected=$(sh "$cmdfile")
# test stdout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not test for exact output from both at once by capturing output in mktemped files?

result=$(echo 5 | "$TRY" "$cmdfile" 2>/dev/null)
expected=$(echo 5 | sh "$cmdfile" 2>/dev/null)

[ "$result" = "$expected" ] || exit 1

# test stdout + stderr
result=$(echo 5 | "$TRY" "$cmdfile" 2>&1)

# using grep because stdout also includes try err/warns
echo $result | grep 15 > /dev/null
Loading