Skip to content

Commit 8b79c9d

Browse files
committed
test: carry the missing-lock cases into the C++ end-to-end runners case
Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
1 parent b55243b commit 8b79c9d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎tests/e2e/run/runners.cpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ E2E runners{"runners", [] {
181181
expect(fatal(e2e::contains(s::text(r), "differs from mcpp.lock"))) << "the refusal does not say what is wrong: " << s::text(r);
182182
expect(fatal(e2e::contains(s::text(r), "9.9.9 -> 0.0.1"))) << "the refusal does not name which package moved, and to what: " << s::text(r);
183183
q.write("mcpp.lock", lock);
184+
// A lock that is not there is not a lock that differs: the refusal says to record one,
185+
// and a refused --locked writes none for the next run to pass against.
186+
fs::remove(q.at("mcpp.lock"));
187+
r = q.mcpp({"build", "--locked"});
188+
expect(fatal(failed(r))) << "--locked accepted a project with no mcpp.lock";
189+
expect(fatal(e2e::contains(s::text(r), "no readable mcpp.lock"))) << "the refusal does not say the lock is missing: " << s::text(r);
190+
expect(fatal(!q.exists("mcpp.lock"))) << "a refused --locked wrote mcpp.lock";
191+
q.write("mcpp.lock", lock);
184192
r = q.mcpp({"emit", "sbom", "-o", "sbom.json"});
185193
expect(fatal(e2e::succeeded(r))) << "mcpp emit sbom: " << s::text(r);
186194
auto d = s::json_file(q.at("sbom.json"));
@@ -203,6 +211,13 @@ E2E runners{"runners", [] {
203211
if (c["name"] == "cmdline") versions.push_back(c["version"]);
204212
expect(fatal(versions == std::vector<std::string>{"7.7.7"})) << "sbom re-resolved instead of reading the lock";
205213
q.write("mcpp.lock", lock);
214+
// Nothing recorded is said on the narration stream, and the document stays valid.
215+
fs::remove(q.at("mcpp.lock"));
216+
r = q.mcpp({"emit", "sbom"});
217+
expect(fatal(e2e::succeeded(r))) << "mcpp emit sbom with no lock: " << s::text(r);
218+
expect(fatal(e2e::contains(r.err, "no mcpp.lock"))) << "sbom did not say that nothing was recorded: " << r.err;
219+
expect(fatal(s::json(r.out)["components"].empty())) << "sbom with no lock is not a root-only document: " << r.out;
220+
q.write("mcpp.lock", lock);
206221

207222
s::project(work / "bsp", {{"mcpp.toml", "[package]\nname = \"demo-board-rt\"\nversion = \"0.1.0\"\n\n[features]\ndefault = [\"emulator\"]\nemulator = []\nhardware = []\n"},
208223
{"build.mcpp", R"(import mcpp;

0 commit comments

Comments
 (0)