Skip to content

Commit

Permalink
Rename and move cli test to pkg/cli
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 18, 2021
1 parent 1557e14 commit e4e269b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions 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 testfqbin
test: testjq testcli
go test ${VERBOSE} ${COVER} ${PKGS}

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

.PHONY: testfqbin
testfqbin:
dev/fqbin-test.sh
.PHONY: testcli
testcli:
@pkg/cli/test.sh pkg/cli/test.exp

.PHONY: doc
doc: doc/file.mp3 doc/file.mp4
Expand Down
1 change: 1 addition & 0 deletions dev/fqbin-test.exp → pkg/cli/test.exp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env expect
# TODO: move this script somehwere else
# TODO: run without NODECODEPROGRESS
# TODO: test interrupt?

log_user 1
set timeout 1
Expand Down
10 changes: 5 additions & 5 deletions dev/fqbin-test.sh → pkg/cli/test.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/sh
set -eu

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
PATH="${TEMPDIR}:${PATH}" expect "$1" >"${TEMPDIR}/fq.log" && FAIL=0 || FAIL=1
if [ $FAIL = "1" ]; then
cat "${TEMPDIR}/fq.log"
fi
rm -rf "${TEMPDIR}"
if [ $EXIT != "0" ]; then
if [ $FAIL = "1" ]; then
exit 1
fi
else
echo "fq-test.sh: skip as expect is not installed"
echo "skip as expect is not installed"
fi

0 comments on commit e4e269b

Please sign in to comment.