aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-05-14 17:08:57 -0400
committerSam Anthony <sam@samanthony.xyz>2026-05-14 17:08:57 -0400
commit28a5aa8c8e7a61dbf06a2cd72ea1bfdee8e67ba6 (patch)
treee01376695417bb6ba1bde4f33c3c74405ae393f6
parent8b39d27eea85691cc45e7d6798060e110e627806 (diff)
downloadlulu-28a5aa8c8e7a61dbf06a2cd72ea1bfdee8e67ba6.zip
cli: test cover-dimensions
-rw-r--r--.gitignore2
-rw-r--r--Makefile16
-rw-r--r--cmd/lulu/flag.go2
-rw-r--r--cmd/lulu/main.go2
-rwxr-xr-xcmd/lulu/test29
-rw-r--r--cmd/lulu/testdata/cd1
-rw-r--r--cmd/lulu/tests/cd1
-rw-r--r--cmd/lulu/tests/cd_nomfg2
8 files changed, 49 insertions, 6 deletions
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: <Expected >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