Files
blossom/tests/commands/main.sakura
T

42 lines
1.6 KiB
Plaintext
Raw Normal View History

2026-10-24 12:13:52 -05:00
# Runs blossom's tests of its commands. Each makes projects in a folder of its
# own, runs the blossom it's given first on them, and compares what it says and
# what it makes with what's expected. blossom's config in that folder names the
# `sakura` that `SAKURA` names, where it's set, as `blossom test` sets it, and
# as its `std` the standard library blossom's own project reads, as `blossom
# libraries` lists it run where the tests are, so they don't depend on a std
# found beside that `sakura`:
#
# blossom test --only blossom.commands
#
# or, from the root of the repository, with a blossom built:
#
# SAKURA=SAKURA sakura run tests/commands/*.sakura -- BLOSSOM
#
# Add `--only TEXT` after BLOSSOM to run those whose name holds the text, and
# `--here` to run them in one program, as a debugger wants. They run `git`, `sh`,
# and `tar`, so they run on Linux.
import std::io;
import std::process;
import system;
import std::testing;
def main(args: span<strview>): void {
if args.length == 0 || args[0].starts_with("-") {
io::println("blossom's tests are given the blossom they run first, as `-- .blossom/KEY/bin/blossom`.");
exit(2);
}
if process::variable("SAKURA") is none {
io::println("blossom's tests run the `sakura` that `SAKURA` names, as `blossom test` sets it.");
exit(2);
}
blossom_at = args[0];
var listing := process::command::new(blossom_at);
listing.arguments(["libraries"]);
val listed := listing.capture() else (why) {
io::println($"blossom's tests can't run `{blossom_at} libraries`: {why}".view());
exit(2);
return;
};
std_at = std_folder(listed.output.view());
exit(tester::run(args));
}