Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(scripts): correct test for externalize-inline to handle inline content

Steven Enamakelcfcbbaceb278
diff --git a/scripts/__tests__/externalize-inline-tests.test.mjs b/scripts/__tests__/externalize-inline-tests.test.mjs
index 798ab0d985..0c2b2acc8b 100644
--- a/scripts/__tests__/externalize-inline-tests.test.mjs
+++ b/scripts/__tests__/externalize-inline-tests.test.mjs
@@ -54,6 +54,21 @@ test("keeps sibling attributes and names extra modules after the module", () =>
assert.match(out.source, /#\[path = "lib_fixtures_tests.rs"\]\nmod fixtures;/);
});
+test("reads a multi-line attribute, and leaves a non-test module behind one alone", () => {
+ const lint = "#[allow(\n missing_docs,\n reason = \"generated\"\n)]\npub(crate) mod exports {\n fn a() {}\n}\n";
+ const plain = externalizeSource(lint, "lib");
+ assert.equal(plain.moves.length, 0);
+ assert.deepEqual(plain.skipped, []);
+
+ const gated = "#[cfg(test)]\n#[allow(\n missing_docs,\n reason = \"fixture\"\n)]\nmod tests {\n fn a() {}\n}\n";
+ const out = externalizeSource(gated, "lib");
+ assert.equal(out.moves.length, 1);
+ assert.equal(
+ out.source,
+ '#[cfg(test)]\n#[allow(\n missing_docs,\n reason = "fixture"\n)]\n#[path = "lib_tests.rs"]\nmod tests;\n',
+ );
+});
+
test("leaves cfg(not(test)) and plain inline modules alone", () => {
const src = "#[cfg(not(test))]\nmod real {\n fn a() {}\n}\nmod plain {\n fn b() {}\n}\n";
const out = externalizeSource(src, "lib");