From dfd39f0b14794b360fd6c961c65ab45d229e00b1 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 22 Jul 2018 13:59:08 -0700 Subject: Shifting further towards having inline tests. Also added a helper function for directly extracting source lines from a Source or AST. --- tools/test.nom | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 tools/test.nom (limited to 'tools/test.nom') diff --git a/tools/test.nom b/tools/test.nom new file mode 100755 index 0000000..3d3329f --- /dev/null +++ b/tools/test.nom @@ -0,0 +1,31 @@ +#!/usr/bin/env nomsu -V2.5.4.3 +use "core" +use "lib/os.nom" +use "lib/consolecolor.nom" + +%args = (command line args) +if (%args.1 == "-v"): + remove index 1 from %args + %verbose = (yes) + +%tests = ((=lua "Source:from_string(\%s)") = %t for %s = %t in (tests)) +for %path in (command line args): + if (%path is "-i"): %inplace = (yes) + for file %filename in %path: + unless (%filename matches "%.nom$"): do next %filename + %file_tests = [] + for %src = %test in %tests: + if (%src.filename == %filename): + add {test:%test, source:%src} to %file_tests + unless (%file_tests is empty): + sort %file_tests by % -> %.source + lua> "io.write('[ .. ] ', \%filename); io.flush()" + if %verbose: say "" + for % in %file_tests: + if %verbose: + say " \(yellow (%.test with "\n" replaced by "\n "))" + run %.test + if %verbose: + say (green "PASS") + ..else: + say "\r[\(green "PASS")" -- cgit v1.2.3