Split the machine from its front end, and add Voyager
The Segan Voyager is the same SplitBit with a screen and a speaker instead of a terminal, and this is the rung that makes there be two of them at all. Everything that is actually the machine - the CPU, the controller, the devices, the run loop, the reporting - moves to machine.c, and each front end brings one file of its own. emulator.c is now sixty lines of argument handling and a three line loop. The machine runs in SLICES rather than to completion, because that is the cut a window needs: run a slice, present a frame, run another. A terminal runs slices until the machine stops. Both loops are three lines, which is why the cut is there rather than anywhere else. At this stage Voyager's window is empty. There is no video device yet and inventing a temporary way to draw would mean building something to throw away. PLAIN MAKE STILL WORKS WITH NO GRAPHICS LIBRARY. Raylib is probed by compiling and linking against it rather than by looking for a file, because a header with no library behind it passes a file check and then fails at link time. Where it is missing, make says so once and builds everything else - the machine, the assembler, the disk tool, the linter and the whole suite. A project about a small understandable CPU should not need OpenGL to run its tests. That nearly broke here: make strict globs Source/Emulator/*.c, so it would have tried to compile voyager.c and failed on precisely the machines the split exists to support, and this machine has Raylib so nothing would have caught it. Tests/voyager.sh runs the WHOLE MANIFEST through Voyager and holds it to the recorded results SplitBit is held to. Not that the two look alike: that one satisfies every recording the other does, byte for byte, exit status included. It reuses run.sh, which now takes the machine from SPLITBIT_EMULATOR, rather than keeping a second copy of the runner that would drift. Voyager not being built is not a failure - it says so and passes. Verified both ways. Made Voyager print one extra line, and 114 of 165 failed: exactly the tests that run the emulator, with the 51 assemble-only and xfail cases correctly untouched. Removed the binary, and the script skipped. Built with HAVE_RAYLIB=no, and everything else still built and checked clean. --headless is taken out of the arguments in voyager.c rather than in the shared parser, which should not learn about a window only one binary has. It exists so the suite can run this binary at all: a front end that could only be exercised by a person looking at it would be a front end nothing checks. loadFile takes a const char * now, which it always should have. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
4c3eac8d9c
commit
e3ef25e3b3
+4
-2
@@ -668,9 +668,11 @@ elif int(said.group(1)) != pairs:
|
||||
#
|
||||
# Claimed in both documents, so both are read.
|
||||
makefile = open("makefile").read()
|
||||
built = re.search(r"^all:(.*)$", makefile, re.M)
|
||||
# TOOLS rather than the all target, which now depends on whether Raylib is installed.
|
||||
# What "the tools" means should be a fact in one place, not read off a conditional.
|
||||
built = re.search(r"^TOOLS = (.*)$", makefile, re.M)
|
||||
if not built:
|
||||
problems.append("the makefile no longer has an all target this can count")
|
||||
problems.append("the makefile no longer has a TOOLS list this can count")
|
||||
else:
|
||||
tools = len(built.group(1).split())
|
||||
for where, text in (("README", rootReadme), ("Test Manual", manual)):
|
||||
|
||||
+15
-4
@@ -23,7 +23,16 @@ INPUT="$TESTS/input"
|
||||
MANIFEST="$TESTS/manifest"
|
||||
|
||||
ASSEMBLER="$ROOT/Assembler"
|
||||
EMULATOR="$ROOT/SplitBit"
|
||||
|
||||
# ---- Which machine runs the programs ----
|
||||
#
|
||||
# SplitBit unless something says otherwise. Tests/voyager.sh sets these to run the whole
|
||||
# manifest through the OTHER front end and hold it to the same recorded results, which is
|
||||
# the strongest thing that can be said about the two of them: not that they look alike, but
|
||||
# that one satisfies every recording the other does. Doing it this way rather than by
|
||||
# copying this file means the two can never be tested differently by accident.
|
||||
EMULATOR="${SPLITBIT_EMULATOR:-$ROOT/SplitBit}"
|
||||
read -r -a EMULATOR_EXTRA <<< "${SPLITBIT_EMULATOR_ARGS:-}"
|
||||
|
||||
RUN_TIMEOUT=10
|
||||
|
||||
@@ -221,7 +230,7 @@ while IFS='|' read -r name src mode stdin limit disk; do
|
||||
# --fast because there is nothing to learn from waiting out the emulated
|
||||
# clock, and --cycles for programs that never halt on their own, which
|
||||
# bounds them by cycle count rather than by wall clock.
|
||||
EMUARGS=(--fast)
|
||||
EMUARGS=(--fast "${EMULATOR_EXTRA[@]}")
|
||||
[ "$limit" != "-" ] && EMUARGS+=(--cycles "$limit")
|
||||
# A disk starts fresh for every run, so a test cannot pass because of what a
|
||||
# previous one left lying on it. The emulator makes the image if it is
|
||||
@@ -284,9 +293,11 @@ if [ "$BLESS" -eq 1 ]; then
|
||||
echo "Recorded $BLESSED expected results into Tests/expected."
|
||||
exit 0
|
||||
fi
|
||||
WHICH=""
|
||||
[ "$EMULATOR" = "$ROOT/SplitBit" ] || WHICH=" under $(basename "$EMULATOR")"
|
||||
if [ "$FAIL" -eq 0 ]; then
|
||||
echo "All $PASS tests passed."
|
||||
echo "All $PASS tests passed$WHICH."
|
||||
exit 0
|
||||
fi
|
||||
echo "$PASS passed, $FAIL failed: ${FAILED_NAMES[*]}"
|
||||
echo "$PASS passed, $FAIL failed$WHICH: ${FAILED_NAMES[*]}"
|
||||
exit 1
|
||||
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# Checks that Voyager is the same machine as SplitBit.
|
||||
#
|
||||
# They share every line of the machine and differ only in what they present, and the way to
|
||||
# keep that true is to make the claim testable rather than to promise it in a comment. So
|
||||
# this runs the WHOLE MANIFEST through Voyager and holds it to the recorded results that
|
||||
# SplitBit is held to - not that the two look alike, but that one satisfies every recording
|
||||
# the other does, byte for byte, exit status included.
|
||||
#
|
||||
# It reuses Tests/run.sh rather than repeating it. A copy of the runner that drove the other
|
||||
# binary would drift from this one, and the first thing to go would be whichever awkward
|
||||
# case was added to only one of them.
|
||||
#
|
||||
# Voyager needs a window, and a machine running tests usually has no display, so it is run
|
||||
# with --headless. That flag exists for this: a front end that could only be exercised by a
|
||||
# person looking at it would be a front end nothing checks.
|
||||
#
|
||||
# Written by Anachronaut
|
||||
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
|
||||
# ---- Not built is not a failure ----
|
||||
#
|
||||
# Voyager is built only where Raylib is, and the whole point of the split is that everything
|
||||
# else works without it. A suite that failed here on a machine with no graphics library
|
||||
# would be enforcing exactly the dependency the split exists to avoid.
|
||||
if [ ! -x "$ROOT/Voyager" ]; then
|
||||
echo "Voyager is not built, so it was not checked. Raylib is what it needs."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Checking that Voyager is the same machine."
|
||||
SPLITBIT_EMULATOR="$ROOT/Voyager" SPLITBIT_EMULATOR_ARGS="--headless" "$ROOT/Tests/run.sh" \
|
||||
| tail -3
|
||||
exit "${PIPESTATUS[0]}"
|
||||
Reference in New Issue
Block a user