Updates to `tests/` for release. Mostly adding comments and improving the README.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Sat, 28 Mar 2020 02:59:26 +0000 (19:59 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Sat, 28 Mar 2020 02:59:26 +0000 (19:59 -0700)
tests/4002_flowcontrol_unconditional_jump_to_label.pvvs
tests/Makefile
tests/README.md
tests/vv_test.py

index 8e0e6d9..7973bcb 100644 (file)
@@ -1,5 +1,5 @@
 # This test verifies the flow control IMP for marking labels and
 # This test verifies the flow control IMP for marking labels and
-# unconditionally jumping to them..
+# unconditionally jumping to them.
 
 SSSTSSSSSTN     | ST: Push +65 (ASCII A)
 NSNTSTSTSN      | FC: Unconditional jump -> '42'
 
 SSSTSSSSSTN     | ST: Push +65 (ASCII A)
 NSNTSTSTSN      | FC: Unconditional jump -> '42'
index 1660851..7231c49 100644 (file)
@@ -1,5 +1,5 @@
 # (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
 # (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
-# All rights reserved.
+# See LICENSE.txt file for copyright and license details.
 
 all: test
 
 
 all: test
 
index ba26732..9a3e0f9 100644 (file)
@@ -1 +1,43 @@
-This folder contains tests for `vvi` that are called from `vv_test.py`.
+# Overview #
+
+This folder contains tests for the VVhitespace interpreter (`vvi`).
+
+# Instructions #
+
+Edit the shebang in `vv_test.py` to match your environment. For example:
+
+    FreeBSD 12: #!/usr/local/bin/python3.6
+    Debian 9  : #!/usr/bin/python3
+
+Build `vvc` and `vvi` in the source tree, if you haven't already.
+
+    vvs-repo/tests % cd .. && make clean all && cd tests
+
+Alternatively, edit the configuration block in `vv_test.py` to provide
+appropriate paths relative to this `tests` folder. 
+
+    compiler_path = '../vvc'
+    interpreter_path = '../vvi'
+
+With configuration now complete, execute the tests via `make test`.  A dot will
+appear for every successfully completed test. For example:
+
+    vvs-repo/tests % make test
+    Testing vvi:
+    .......................
+    vvs-repo/tests %
+
+If a test should fail, the name of the test will be printed in place of its
+dot.  For example, with an induced failure in the division command:
+
+    vvs-repo/tests % make test
+    Testing vvi:
+    ........
+    2004_arithmetic_division
+        Expected: A
+        Received: A113
+    ..............
+    vvs-repo/tests %
+
+If testing is aborted prematurely, say by a Ctrl-C initiated SIGINT, use `make
+clean` to remove any temporary files.
index fd7ab78..fddee29 100755 (executable)
@@ -1,20 +1,23 @@
 #!/usr/local/bin/python3.6
 
 # (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
 #!/usr/local/bin/python3.6
 
 # (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
-# All rights reserved.
+# See LICENSE.txt file for copyright and license details.
 
 # Quick and dirty tests for the VVhitespace interpreter.
 
 # Quick and dirty tests for the VVhitespace interpreter.
+# Invoke directly or see README.md in this folder for more details.
 
 
-import os, subprocess
-
+# Configuration Options
+# All paths are relative to the PWD environment variable of the invoked script.
 compiler_path = '../vvc'
 interpreter_path = '../vvi'
 temp_file = './test.vvs'
 path_to_tests = './'
 src_extension = '.pvvs'
 
 compiler_path = '../vvc'
 interpreter_path = '../vvi'
 temp_file = './test.vvs'
 path_to_tests = './'
 src_extension = '.pvvs'
 
+# List of tests to perform.
+# Tests should be ordered such that later tests rely exclusively on previously tested commands.
+# Test Entry Format: ['filename_without_extension', 'string for stdin', 'string for expected stdout']
 tests = [
 tests = [
-        # Format: ['filename_without_extension', 'string for stdin', 'string for expected stdout']
         ['0001_push_printchar_exit', '', 'A'],
         ['1001_stack_push', '', 'A'],
         ['1002_stack_dup', '', 'AA'],
         ['0001_push_printchar_exit', '', 'A'],
         ['1001_stack_push', '', 'A'],
         ['1002_stack_dup', '', 'AA'],
@@ -40,11 +43,17 @@ tests = [
         ['6001_push_intmin', '', '1'],
         ] 
 
         ['6001_push_intmin', '', '1'],
         ] 
 
+# ------------------------------------------------------------------------------
+
+import os, subprocess
+
 for test in tests:
     subprocess.run([compiler_path, '-i', path_to_tests + test[0] + src_extension, '-o', temp_file])
     result = subprocess.run([interpreter_path, '-i', temp_file], stdout=subprocess.PIPE, input=test[1].encode('utf-8'))
     if result.stdout.decode('utf-8') != test[2]:
         print('\n' + test[0])
 for test in tests:
     subprocess.run([compiler_path, '-i', path_to_tests + test[0] + src_extension, '-o', temp_file])
     result = subprocess.run([interpreter_path, '-i', temp_file], stdout=subprocess.PIPE, input=test[1].encode('utf-8'))
     if result.stdout.decode('utf-8') != test[2]:
         print('\n' + test[0])
+        print('\tExpected: ' + test[2])
+        print('\tReceived: ' + result.stdout.decode('utf-8'))
     else:
         print('.', end='', flush=True)
     os.remove(temp_file)
     else:
         print('.', end='', flush=True)
     os.remove(temp_file)