Verify and publish documentation / test (macos-latest) (push) Canceled after 0s
Verify and publish documentation / test (ubuntu-latest) (push) Canceled after 0s
Verify and publish documentation / docs (push) Canceled after 0s
Verify and publish documentation / deploy (push) Canceled after 0s
Validate physical cards and CLI arguments, guard live DO cells, and share word encoding and checked numeric conversion. Preserve media on failed runs and bound notebook input, output, execution time and process cleanup. Clarify fixed-form editor support and compatibility evidence, add executable quick-start examples, and gate GitHub Pages on Linux/macOS and strict docs CI.
53 lines
2.4 KiB
Python
53 lines
2.4 KiB
Python
"""Run the published quick-start examples in a clean working directory."""
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
BIN = os.environ.get("F704_BINARY", str(ROOT / "fortran704"))
|
|
if "/" in BIN:
|
|
BIN = str(Path(BIN).resolve())
|
|
|
|
|
|
class DocumentationExamples(unittest.TestCase):
|
|
def run_deck(self, work, *args, data=None):
|
|
result = subprocess.run([str(BIN), *map(str, args)], cwd=work,
|
|
input=data, capture_output=True, timeout=15)
|
|
self.assertEqual(result.returncode, 0, result.stderr.decode())
|
|
return result
|
|
|
|
def test_quick_start_and_input(self):
|
|
with tempfile.TemporaryDirectory() as work:
|
|
hello = self.run_deck(work, ROOT / "tests/hello.f")
|
|
self.assertEqual(hello.stdout, (ROOT / "tests/hello.out").read_bytes())
|
|
self.assertEqual(hello.stderr, b"STOP 0\n")
|
|
read = self.run_deck(work, ROOT / "tests/read.f",
|
|
data=(ROOT / "tests/read.in").read_bytes())
|
|
self.assertEqual(read.stdout, (ROOT / "tests/read.out").read_bytes())
|
|
text = (ROOT / "docs/getting-started.md").read_text()
|
|
deck = text.split("```fortran\n", 1)[1].split("```", 1)[0]
|
|
source = Path(work) / "example.f"
|
|
source.write_text(deck)
|
|
self.assertEqual(self.run_deck(work, source).stdout.split(), [b"1.25"])
|
|
|
|
def test_published_media_pair(self):
|
|
with tempfile.TemporaryDirectory() as work:
|
|
work = Path(work)
|
|
self.run_deck(work, "--debug-script", ROOT / "examples/debug-media/commands.txt",
|
|
"--debug-output", "trace.txt", "--save-media", "state.f704m",
|
|
"--export-text", "1", "exchange.txt", ROOT / "examples/debug-media/write.f")
|
|
output = self.run_deck(work, "--load-media", "state.f704m",
|
|
ROOT / "examples/debug-media/read.f")
|
|
self.assertEqual(output.stdout.split(), [b"7", b"1.25", b"1.25"])
|
|
self.assertEqual((work / "exchange.txt").read_bytes(),
|
|
(ROOT / "examples/debug-media/exchange.txt").read_bytes())
|
|
trace = (work / "trace.txt").read_text()
|
|
self.assertIn("checkpoint", trace)
|
|
self.assertIn("kind=BCD", trace)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|