Skip to content

Commit

Permalink
fq: Add cli sanity test
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 18, 2021
1 parent 1fe5d95 commit 46d37ef
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fq:
.PHONY: test
# figure out all go pakges with test files
test: PKGS=$(shell find . -name "*_test.go" | xargs -n 1 dirname | sort | uniq)
test: testjq
test: testjq testfqbin
go test ${VERBOSE} ${COVER} ${PKGS}

testwrite: export WRITE_ACTUAL=1
Expand All @@ -29,6 +29,10 @@ testjq:
go run main.go -L "$$(dirname $$f)" -f "$$f" -n -r ; \
done

.PHONY: testfqbin
testfqbin:
dev/fqbin-test.sh

.PHONY: doc
doc: doc/file.mp3 doc/file.mp4
$(eval REPODIR=$(shell pwd))
Expand Down
28 changes: 28 additions & 0 deletions dev/fqbin-test.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env expect
# TODO: move this script somehwere else
# TODO: run without NODECODEPROGRESS

log_user 1
set timeout 1

expect_after {
timeout {exit 1}
}

spawn sh -c "NODECODEPROGRESS=1 fq -o color=false -i . pkg/interp/testdata/test.mp3 2>&1"

expect "mp3> "

send ".\n"
expect "footers"
expect "mp3> "

send ".frames | mp3_fr\t"
expect "mp3_frame"
send "\n"
expect "side_info"

# ctrl-d
send "\x04"

expect eof
17 changes: 17 additions & 0 deletions dev/fqbin-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

if which expect >/dev/null 2>&1; then
TEMPDIR=$(mktemp -d)
go build -o "${TEMPDIR}/fq" main.go
PATH="${TEMPDIR}:${PATH}" expect dev/fqbin-test.exp >"${TEMPDIR}/fq.log"
EXIT="$?"
if [ $EXIT != "0" ]; then
cat "${TEMPDIR}/fq.log"
fi
rm -rf "${TEMPDIR}"
if [ $EXIT != "0" ]; then
exit 1
fi
else
echo "fq-test.sh: skip as expect is not installed"
fi

0 comments on commit 46d37ef

Please sign in to comment.