shithub: rech

Download patch

ref: 982ba593935d007955d7d53f69622af34b3436ab
parent: 00e5cf965166c614977ac549d9361d63d5edba02
author: sirjofri <sirjofri@sirjofri.de>
date: Wed Aug 6 16:25:46 EDT 2025

adds test scripts

--- a/README
+++ b/README
@@ -1,3 +1,10 @@
+MKFILE RULES
+
+- all: test and build everything
+- test: run some tests
+- invoices: build invoices
+
+
 FOLDERS
 
 - /bin contains helper scripts that don't fit into the mkfile
@@ -38,6 +45,7 @@
 
 - name: actual letter template
 - name.msg: default message for that template
+- name.sed: string replace sed functions for "variables"
 
 
 The client files are:
--- /dev/null
+++ b/bin/test/vmissingfiles
@@ -1,0 +1,32 @@
+#!/bin/rc
+
+rfork en
+
+fn testfile{
+	test -f $1 || echo ! missing file $1 >[1=2]
+}
+fn testfileo{
+	test -f $1 || echo missing optional file $1 >[1=2]
+}
+
+templates=`{cd template; walk -n 1 | grep -v '\.'}
+for (t in $templates) {
+	testfile template/$t.msg
+	testfile template/$t.sed
+}
+
+invoices=`{cd invoice; walk -d -n 1}
+for (i in $invoices) {
+	testfile invoice/$i/client
+	testfile invoice/$i/data.tsv
+	testfile invoice/$i/date
+	testfile invoice/$i/template
+	testfileo invoice/$i/msg
+}
+
+clients=`{cd client; walk -d -n 1}
+for (c in $clients) {
+	testfile client/$c/addr
+	testfileo client/$c/msg
+	testfileo client/$c/vcard.vcf
+}
--- /dev/null
+++ b/bin/test/vvariables
@@ -1,0 +1,17 @@
+#!/bin/rc
+
+rfork en
+
+fn exist{
+	grep -s '##'^$1^'##' $file || echo `{basename $file}: missing variable $1 >[1=2]
+}
+
+vars=( ROW_NAME ROW_COUNT ROW_PRICE ROW_TAX ROW_TOTAL SUBTOTAL VAT_TOTAL TOTAL )
+
+sedfiles=`{cd template; walk -n1 | grep '\.sed$'}
+for (file in $sedfiles) {
+	file=`{echo template/$file}
+	for (v in $vars) {
+		exist $v
+	}
+}
--- a/mkfile
+++ b/mkfile
@@ -1,10 +1,14 @@
 invoices=`{cd invoice; walk -d -n 1}
 targets=`{for (f in $invoices) { echo invoice/^$f^/invoice-^$f^.pdf }}
 
-all:V: $targets
+all:V: test invoices
 
 test:VQ:
-	
+	# run tests for data integrity
+	bin/test/vmissingfiles
+	bin/test/vvariables
+
+invoices:VQ: $targets
 
 invoice/([^/]+)/invoice-([^/]+).pdf:RQ: invoice/\1/template invoice/\1/data.tsv
 	rfork en
--