aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-03 14:01:35 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-03 14:01:35 -0400
commitfce1044b648a3b568ccc080acf2d554ae8251c84 (patch)
treed73fd3af0896bbc5f657f11e84ec25e8a93c0be3 /test
parent34a95f255f9d557dadb18e98663cb7aa01da3288 (diff)
Add tester for an arbitrary executable via stdin/stdout
Diffstat (limited to 'test')
-rwxr-xr-xtest/exe16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/exe b/test/exe
new file mode 100755
index 00000000..fdf0acd3
--- /dev/null
+++ b/test/exe
@@ -0,0 +1,16 @@
+#! /usr/bin/env dbqn
+
+"usage: exe name [opts --] [tests]"!1≤≠•args
+
+# BQN is called with the first argument, or all up to the last --
+files‿exe ← •args ⊔˜ 2 ∾˜ ⊑◶⟨1⌾⊑,«⊸(⊣-<)⟩ ∨`⌾⌽ •args≡¨<"--"
+
+files ↩ ⟨"prim"⟩⍟(0=≠) files
+
+Include ← '%'⊸(∧´≠) ∧ (0<≠)◶0‿('#'≠⊑)
+Cases ← Include¨⊸/ · •FLines "cases/"∾∾⟜".bqn"
+c ← ∾ Cases¨ files
+code‿r‿err ← {inp⇐∾∾⟜(@+10)¨c∾⟨""⟩} •SH exe
+err ! 0≡code
+rv ← •BQN "⟨"∾r∾"⟩"
+•Out (0<≠)◶⟨"All "∾(⍕≠c)∾" passed!"˙,(⍕≠)∾" failed!"˙⟩ /1≢¨rv