commit 376c7501d5235756786012fef523c95297d8d605
parent 5ba83b1bd7b6a2193bb197952c18bbca99bc89db
Author: Sean Enck <sean@ttypty.com>
Date: Sun, 19 Feb 2023 07:48:59 -0500
test area is a little less messy
Diffstat:
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,5 +1,6 @@
BUILD := bin/
TARGET := $(BUILD)lb
+TESTS := scripts/testing
all: $(TARGET)
@@ -13,7 +14,8 @@ unittest:
go test -v ./...
check: $(TARGET) unittest
- make -C scripts/testing LB_BUILD=$(PWD)/$(TARGET) TEST_DATA=$(PWD)/$(BUILD) SCRIPTS=$(PWD)/scripts/testing/
+ LB_BUILD=$(PWD)/$(TARGET) make -C $(TESTS)
clean:
rm -rf $(BUILD)
+ make -C $(TESTS) clean
diff --git a/scripts/testing/Makefile b/scripts/testing/Makefile
@@ -1,10 +1,15 @@
-ACTUAL := $(TEST_DATA)actual.log
+BIN := bin
+ACTUAL := $(BIN)/actual.log
RUNS := -keyfile=true -keyfile=false
DATE := $(date +%Y-%m-%d)
all: $(RUNS)
$(RUNS):
- rm -f $(TEST_DATA)*.kdbx
- LB_BUILD=$(LB_BUILD) TEST_DATA=$(TEST_DATA) SCRIPTS=$(SCRIPTS) go run check.go $@ 2>&1 | sed "s#$(PWD)/$(DATA)##g" | sed 's/^[0-9][0-9][0-9][0-9][0-9][0-9]$$/XXXXXX/g' | sed 's/modtime: $(DATE).*/modtime: XXXX-XX-XX/g' > $(ACTUAL)
+ mkdir -p $(BIN)
+ rm -f $(BIN)/*.kdbx
+ LB_BUILD=$(LB_BUILD) go run check.go $@ -data $(BIN) 2>&1 | sed "s#$(PWD)/$(DATA)##g" | sed 's/^[0-9][0-9][0-9][0-9][0-9][0-9]$$/XXXXXX/g' | sed 's/modtime: $(DATE).*/modtime: XXXX-XX-XX/g' > $(ACTUAL)
diff -u $(ACTUAL) expected.log
+
+clean:
+ rm -rf $(BIN)
diff --git a/scripts/testing/check.go b/scripts/testing/check.go
@@ -60,8 +60,13 @@ func totpList() {
func main() {
keyFile := flag.Bool("keyfile", false, "enable keyfile")
+ dataPath := flag.String("data", "", "data area")
flag.Parse()
- path := os.Getenv("TEST_DATA")
+ path := *dataPath
+ cwd, err := os.Getwd()
+ if err != nil {
+ die("failed to get workdir", err)
+ }
useKeyFile := ""
if *keyFile {
useKeyFile = filepath.Join(path, "test.key")
@@ -116,7 +121,7 @@ func main() {
insert("keys/k2/t1/one2", []string{"test2"})
insert("keys/k2/t1/one", []string{"test"})
insert("keys/k2/t2/one2", []string{"test2"})
- os.Setenv("LOCKBOX_HOOKDIR", filepath.Join(os.Getenv("SCRIPTS"), "hooks"))
+ os.Setenv("LOCKBOX_HOOKDIR", filepath.Join(cwd, "hooks"))
insert("keys/k2/t2/one", []string{"test"})
fmt.Println()
ls()