Skip to content

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

feat(scripts): reject test.rs, tests.rs and singular _test.rs filenames

Steven Enamakelaa324624f61f
diff --git a/scripts/__tests__/check-openhuman-rust-layout.test.mjs b/scripts/__tests__/check-openhuman-rust-layout.test.mjs
index 53d76a63c0..fb9925c21c 100644
--- a/scripts/__tests__/check-openhuman-rust-layout.test.mjs
+++ b/scripts/__tests__/check-openhuman-rust-layout.test.mjs
@@ -63,6 +63,16 @@ test("fails one line over the limit", () => {
assert.match(out, /a\.rs: 751 lines \(limit 750\)/);
});
+test("rejects test.rs, tests.rs and the singular <name>_test.rs", () => {
+ for (const name of ["test.rs", "tests.rs", "thing_test.rs"]) {
+ const { status, out } = run({ [name]: 1 });
+ assert.equal(status, 1, name);
+ assert.match(out, /must use a descriptive \*_tests\.rs filename/);
+ }
+ const ok = run({ "thing_tests.rs": 1 });
+ assert.equal(ok.status, 0, ok.out);
+});
+
test("warns, without failing, on a file inside the warn band", () => {
const { status, out } = run({ "near.rs": 740, "far.rs": 725 });
assert.equal(status, 0, out);
diff --git a/scripts/ci/check-openhuman-rust-layout.mjs b/scripts/ci/check-openhuman-rust-layout.mjs
index f9f4acd0dd..fd2eca6fae 100644
--- a/scripts/ci/check-openhuman-rust-layout.mjs
+++ b/scripts/ci/check-openhuman-rust-layout.mjs
@@ -108,7 +108,10 @@ for (const file of allRustFiles(ROOT)) {
for (const file of allRustFiles(CRATES_ROOT)) {
const source = fs.readFileSync(file, "utf8");
- if (["tests.rs", "test.rs"].includes(path.basename(file))) {
+ if (
+ ["tests.rs", "test.rs"].includes(path.basename(file)) ||
+ path.basename(file).endsWith("_test.rs")
+ ) {
failures.push(
`${file}: test modules must use a descriptive *_tests.rs filename`,
);