Files

45 lines
1.9 KiB
Plaintext
Raw Permalink 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 --suite blossom.commands
#
# with `--test TEXT` to run those whose names hold the text; 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. Each test's folder
# is in the system's temporary folder, and blossom's config and store are the
# folder's, on Linux and on Windows alike. They run `git` and `tar`, and blossom
# runs `gzip` to package, each found on `PATH`.
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}".span);
exit(2);
return;
};
std_at = std_folder(listed.output.span);
exit(tester::run(args));
}