1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
-- The entry script of a project split across files. Everything it needs it requires, and
-- everything it can require lives under its own directory.
--
-- Every line of this example's output is written from here rather than from the host, and the
-- heading arrives as an argument for that reason. Not an ordering constraint: Lua's `print` and
-- Rust's `println!` both flush per line and interleave correctly. It is that every line below is
-- put through `stable` to redact the project root, and a heading printed from Rust would be the
-- one line in the block that had not been.
--
-- The project directory arrives the same way: a `require` refusal names the root it searched, and
-- an absolute path differs on every machine.
-- Both arguments are optional, so `airsl run app.lua` works on its own. Without them the refusals
-- below name the real directory, which is the right answer for someone running this by hand and
-- the wrong one for output that has to be diffed.
local root, heading = arg or "", arg or ""
--- Replaces every literal occurrence of `needle` — `string.find` in plain mode, because a path
--- contains `-` and `.`, which Lua patterns would read as syntax.
local
--- The first line of `message`, with the project directory replaced by its role. The traceback
--- after that line names absolute paths, which belong nowhere near output meant to be diffed.
local
--- Requires `name`, printing the refusal instead of propagating it.
local
if heading ~= ""
-- Counts this script's own evaluations, so the two facts can be read side by side: the number goes
-- up on a reused engine while the list of module bodies below it does not.
EVALUATIONS = + 1
-- --- the module tree --------------------------------------------------------------------------
-- A directory module: there is no `lib.lua`, so this resolves through `lib/init.lua`.
local lib = require
-- A dot separates path components, so this is `lib/text.lua`. `lib/init.lua` has already required
-- it, and this second call gets the table that one produced rather than running the file again.
local text = require
print
print
print
print
print
-- --- what a target may not name ---------------------------------------------------------------
-- Not a path check that failed. `..` has no spelling as a target at all, so the name is refused
-- before any path is built — there is nothing for the filesystem to be asked about.
expect_refusal
-- A well-formed name for a file that is not there. The message names the directory searched, which
-- is the whole search: there is no second place to look.
expect_refusal
-- A chain that closes on itself, answered rather than recursed into.
expect_refusal