From e4e269b162a7686145dde4f7fc77653c8d3e4a2c Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Sat, 18 Sep 2021 18:23:28 +0200 Subject: [PATCH] Rename and move cli test to pkg/cli --- Makefile | 8 ++++---- dev/fqbin-test.exp => pkg/cli/test.exp | 1 + dev/fqbin-test.sh => pkg/cli/test.sh | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) rename dev/fqbin-test.exp => pkg/cli/test.exp (94%) rename dev/fqbin-test.sh => pkg/cli/test.sh (50%) diff --git a/Makefile b/Makefile index fe3c784a..79051c92 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/dev/fqbin-test.exp b/pkg/cli/test.exp similarity index 94% rename from dev/fqbin-test.exp rename to pkg/cli/test.exp index ccd67a55..c1b8ef0c 100755 --- a/dev/fqbin-test.exp +++ b/pkg/cli/test.exp @@ -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 diff --git a/dev/fqbin-test.sh b/pkg/cli/test.sh similarity index 50% rename from dev/fqbin-test.sh rename to pkg/cli/test.sh index bee8efd2..85577608 100755 --- a/dev/fqbin-test.sh +++ b/pkg/cli/test.sh @@ -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