From 28a5aa8c8e7a61dbf06a2cd72ea1bfdee8e67ba6 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Thu, 14 May 2026 17:08:57 -0400 Subject: cli: test cover-dimensions --- .gitignore | 2 ++ Makefile | 16 ++++++++++++---- cmd/lulu/flag.go | 2 +- cmd/lulu/main.go | 2 +- cmd/lulu/test | 29 +++++++++++++++++++++++++++++ cmd/lulu/testdata/cd | 1 + cmd/lulu/tests/cd | 1 + cmd/lulu/tests/cd_nomfg | 2 ++ 8 files changed, 49 insertions(+), 6 deletions(-) create mode 100755 cmd/lulu/test create mode 100644 cmd/lulu/testdata/cd create mode 100644 cmd/lulu/tests/cd create mode 100644 cmd/lulu/tests/cd_nomfg diff --git a/.gitignore b/.gitignore index 8f18729..9d2a6ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/cmd/lulu/testout +/.gen /lulu /spec.yml /testdata/clientkey diff --git a/Makefile b/Makefile index c254292..da99711 100644 --- a/Makefile +++ b/Makefile @@ -7,14 +7,22 @@ all: build lulu build: ${SRC} ${GEN} go build -${GEN}: ${SRC} - go generate +testcli: lulu cmd/lulu/test $(wildcard cmd/lulu/tests/*) $(wildcard cmd/lulu/testdata/*) + $(eval PATH=$(shell pwd):${PATH}) + cd cmd/lulu && ./test -lulu: ${SRC} $(wildcard cmd/lulu/*.go) +${GEN}: .gen + +.gen: ${SRC} + go generate && touch $@ + +lulu: ${SRC} ${GEN} $(wildcard cmd/lulu/*.go) go build ./cmd/$@ spec.yml: curl -L -o $@ 'https://api.lulu.com/api-docs/openapi-specs/openapi_public.yml' clean: - rm -f ${GEN} ${BIN} + cat .gitignore | xargs -I{} sh -c "rm -rf ./{}" + +.PHONY: testcli diff --git a/cmd/lulu/flag.go b/cmd/lulu/flag.go index a6592d7..a16aa52 100644 --- a/cmd/lulu/flag.go +++ b/cmd/lulu/flag.go @@ -16,7 +16,7 @@ import ( ) func pkgIdFlag(p *lulu.PkgId, required bool) Flag { - return Flag{&pkgIdValue{p, false}, "mfg", fmt.Sprintf("Manufacturing options (%T)", *p), required} + return Flag{&pkgIdValue{p, false}, "mfg", fmt.Sprintf("%s manufacturing options", typeName(*p)), required} } func nPagesFlag(p *uint, required bool) Flag { diff --git a/cmd/lulu/main.go b/cmd/lulu/main.go index 7cf6bb3..6e6f146 100644 --- a/cmd/lulu/main.go +++ b/cmd/lulu/main.go @@ -132,7 +132,7 @@ func validateInterior(name string, clnt *lulu.Client, args []string) { timeoutFlag(&timeout, false), }, fmt.Sprintf("%s %s %s [flags]\n", name, urlFlag.Synopsis(), mfgFlag.Synopsis()), - fmt.Sprintf(" %s %s %s [flags]\n", name, basicFlag.Synopsis(), urlFlag.Synopsis())) + fmt.Sprintf("%s %s %s [flags]\n", name, basicFlag.Synopsis(), urlFlag.Synopsis())) fs.Parse(args) var val lulu.InteriorValidation diff --git a/cmd/lulu/test b/cmd/lulu/test new file mode 100755 index 0000000..e819005 --- /dev/null +++ b/cmd/lulu/test @@ -0,0 +1,29 @@ +#!/bin/sh + +set -u + +[[ ! -d testout ]] && mkdir testout + +for test in tests/* +do + base=${test##*/} + want=testdata/$base + out=testout/$base + if [ -f $want ]; then + sh $test >$out 2>/dev/null + if ! cmp -s $want $out + then + echo "FAIL $test: Actual" + diff $want $out + exit 1 + fi + else + if sh $test >$out 2>/dev/null + then + echo "FAIL $test: expected error; got \"$(cat $out)\"" + exit 1 + fi + fi +done + +echo ok diff --git a/cmd/lulu/testdata/cd b/cmd/lulu/testdata/cd new file mode 100644 index 0000000..4d81ea7 --- /dev/null +++ b/cmd/lulu/testdata/cd @@ -0,0 +1 @@ +307.870 x 216.410 mm diff --git a/cmd/lulu/tests/cd b/cmd/lulu/tests/cd new file mode 100644 index 0000000..16520fc --- /dev/null +++ b/cmd/lulu/tests/cd @@ -0,0 +1 @@ +lulu -s cd -mfg 0583X0827.BW.PRE.PB.060UW444.MXX -n 67 -u mm diff --git a/cmd/lulu/tests/cd_nomfg b/cmd/lulu/tests/cd_nomfg new file mode 100644 index 0000000..8404fed --- /dev/null +++ b/cmd/lulu/tests/cd_nomfg @@ -0,0 +1,2 @@ +# missing -mfg +lulu -s cd -n 200 -- cgit v1.2.3