|
| 1 | +/** |
| 2 | + * Hardener SHOULDs 4–6 (WheelsTest review slice). |
| 3 | + * |
| 4 | + * Source-scan / existence locks — no live CommandBox, no live runTests HTTP. |
| 5 | + * Same altitude as MainCommandSpec / TestExitFailClosedSpec. |
| 6 | + * |
| 7 | + * SHOULD 4 — guides must teach CLI fail-closed (Wheels.TestsFailed), not |
| 8 | + * "no Fail/Error means exit 0" / ignore directoryRejected. |
| 9 | + * SHOULD 5 — legacy CommandBox cli/src test runners must not be a weaker |
| 10 | + * exit path than LuCLI `wheels test` / `wheels browser test`. |
| 11 | + * SHOULD 6 — vendor/wheels/controllers/Tests.cfc is unrouted and must not |
| 12 | + * ship; allowlisted runners stay on Public.cfc. |
| 13 | + */ |
| 14 | +component extends="wheels.wheelstest.system.BaseSpec" { |
| 15 | + |
| 16 | + function beforeAll() { |
| 17 | + variables.repoRoot = expandPath("/cli/../"); |
| 18 | + variables.guidesRoot = variables.repoRoot & "web/sites/guides/src/content/docs/v4-0-0/"; |
| 19 | + } |
| 20 | + |
| 21 | + function run() { |
| 22 | + |
| 23 | + describe("SHOULD 4 — docs teach fail-closed, not silent full-suite / vacuous exit 0", () => { |
| 24 | + |
| 25 | + it("testing.mdx names Wheels.TestsFailed and the ##3083 honesty signals", () => { |
| 26 | + var src = fileRead(guidesRoot & "command-line-tools/wheels-commands/testing.mdx"); |
| 27 | + expect(src).toInclude("Wheels.TestsFailed"); |
| 28 | + expect(src).toInclude("directoryRejected"); |
| 29 | + expect(src).toInclude("bundlesDiscovered"); |
| 30 | + }); |
| 31 | + |
| 32 | + it("running-framework-tests.mdx says wheels test throws Wheels.TestsFailed", () => { |
| 33 | + var src = fileRead(guidesRoot & "contributing/running-framework-tests.mdx"); |
| 34 | + expect(src).toInclude("Wheels.TestsFailed"); |
| 35 | + }); |
| 36 | + |
| 37 | + it("quick-start.mdx does not teach that a run with no Fail/Error always exits 0", () => { |
| 38 | + var src = fileRead(guidesRoot & "command-line-tools/quick-start.mdx"); |
| 39 | + expect(src).notToInclude("a run with no failures exits `0`"); |
| 40 | + }); |
| 41 | + |
| 42 | + it("running-tests-locally.mdx names Wheels.TestsFailed for the CLI path", () => { |
| 43 | + var src = fileRead(guidesRoot & "testing/running-tests-locally.mdx"); |
| 44 | + expect(src).toInclude("Wheels.TestsFailed"); |
| 45 | + }); |
| 46 | + |
| 47 | + it("ci-integration.mdx gates the CommandBox curl example on directoryRejected / bundlesDiscovered", () => { |
| 48 | + var src = fileRead(guidesRoot & "testing/ci-integration.mdx"); |
| 49 | + expect(src).toInclude("directoryRejected"); |
| 50 | + expect(src).toInclude("bundlesDiscovered"); |
| 51 | + expect(src).toInclude("Wheels.TestsFailed"); |
| 52 | + }); |
| 53 | + |
| 54 | + }); |
| 55 | + |
| 56 | + describe("SHOULD 5 — CommandBox cli/src test runners are not a weaker exit path", () => { |
| 57 | + |
| 58 | + it("test/run.cfc does not swallow TestBox failing exit codes", () => { |
| 59 | + var src = fileRead(expandPath("/cli/src/commands/wheels/test/run.cfc")); |
| 60 | + expect(findNoCase("failing exit code", src)).toBe( |
| 61 | + 0, |
| 62 | + "CommandBox wheels test run must not catch-and-ignore TestBox failing exit codes." |
| 63 | + ); |
| 64 | + }); |
| 65 | + |
| 66 | + it("test/all.cfc does not swallow TestBox failing exit codes", () => { |
| 67 | + var src = fileRead(expandPath("/cli/src/commands/wheels/test/all.cfc")); |
| 68 | + expect(findNoCase("failing exit code", src)).toBe( |
| 69 | + 0, |
| 70 | + "CommandBox wheels test:all must not catch-and-ignore TestBox failing exit codes." |
| 71 | + ); |
| 72 | + }); |
| 73 | + |
| 74 | + it("test/unit.cfc does not swallow TestBox failing exit codes", () => { |
| 75 | + var src = fileRead(expandPath("/cli/src/commands/wheels/test/unit.cfc")); |
| 76 | + expect(findNoCase("failing exit code", src)).toBe( |
| 77 | + 0, |
| 78 | + "CommandBox wheels test:unit must not catch-and-ignore TestBox failing exit codes." |
| 79 | + ); |
| 80 | + }); |
| 81 | + |
| 82 | + it("test/integration.cfc does not swallow TestBox failing exit codes", () => { |
| 83 | + var src = fileRead(expandPath("/cli/src/commands/wheels/test/integration.cfc")); |
| 84 | + expect(findNoCase("failing exit code", src)).toBe( |
| 85 | + 0, |
| 86 | + "CommandBox wheels test:integration must not catch-and-ignore TestBox failing exit codes." |
| 87 | + ); |
| 88 | + }); |
| 89 | + |
| 90 | + it("browser/test.cfc refuses with a deprecation error instead of returning after Fail/Error", () => { |
| 91 | + var src = fileRead(expandPath("/cli/src/commands/wheels/browser/test.cfc")); |
| 92 | + expect(src).toInclude("DEPRECATED"); |
| 93 | + expect(reFindNoCase("error\s*\(", src)).toBeGT( |
| 94 | + 0, |
| 95 | + "CommandBox wheels browser:test must error() so the process cannot exit 0 after Fail/Error." |
| 96 | + ); |
| 97 | + }); |
| 98 | + |
| 99 | + it("legacy CommandBox test runners point operators at LuCLI wheels test", () => { |
| 100 | + var files = [ |
| 101 | + "test/run.cfc", |
| 102 | + "test/all.cfc", |
| 103 | + "test/unit.cfc", |
| 104 | + "test/integration.cfc", |
| 105 | + "test/coverage.cfc", |
| 106 | + "test/watch.cfc", |
| 107 | + "browser/test.cfc" |
| 108 | + ]; |
| 109 | + for (var rel in files) { |
| 110 | + var src = fileRead(expandPath("/cli/src/commands/wheels/" & rel)); |
| 111 | + expect(src).toInclude( |
| 112 | + "DEPRECATED", |
| 113 | + rel & " must refuse with a deprecation instead of offering a weaker exit path." |
| 114 | + ); |
| 115 | + expect(src).toInclude("LuCLI"); |
| 116 | + } |
| 117 | + }); |
| 118 | + |
| 119 | + it("CommandBox test runners do not invoke testbox run after deprecation error()", () => { |
| 120 | + // CommandBox error() prints red and does NOT abort. A later |
| 121 | + // command("testbox run") still executes. C5. |
| 122 | + var files = [ |
| 123 | + "test/run.cfc", |
| 124 | + "test/all.cfc", |
| 125 | + "test/unit.cfc", |
| 126 | + "test/integration.cfc", |
| 127 | + "test/coverage.cfc", |
| 128 | + "test/watch.cfc", |
| 129 | + "browser/test.cfc" |
| 130 | + ]; |
| 131 | + for (var rel in files) { |
| 132 | + var src = fileRead(expandPath("/cli/src/commands/wheels/" & rel)); |
| 133 | + expect(findNoCase("testbox run", src)).toBe( |
| 134 | + 0, |
| 135 | + rel & " must not contain testbox run after error(); CommandBox error() does not abort." |
| 136 | + ); |
| 137 | + } |
| 138 | + }); |
| 139 | + |
| 140 | + it("deprecation error() is followed by return so CommandBox cannot fall through", () => { |
| 141 | + var files = [ |
| 142 | + "test/run.cfc", |
| 143 | + "test/all.cfc", |
| 144 | + "test/unit.cfc", |
| 145 | + "test/integration.cfc", |
| 146 | + "test/coverage.cfc", |
| 147 | + "test/watch.cfc", |
| 148 | + "browser/test.cfc" |
| 149 | + ]; |
| 150 | + for (var rel in files) { |
| 151 | + var src = fileRead(expandPath("/cli/src/commands/wheels/" & rel)); |
| 152 | + expect(reFindNoCase("error\s*\(\s*""DEPRECATED[^;]*;\s*return\s*;", src)).toBeGT( |
| 153 | + 0, |
| 154 | + rel & " must return immediately after error(""DEPRECATED..."") — error() does not abort." |
| 155 | + ); |
| 156 | + } |
| 157 | + }); |
| 158 | + |
| 159 | + }); |
| 160 | + |
| 161 | + describe("SHOULD 6 — orphan vendor/wheels/controllers/Tests.cfc is gone", () => { |
| 162 | + |
| 163 | + it("does not ship vendor/wheels/controllers/Tests.cfc", () => { |
| 164 | + expect(fileExists(expandPath("/vendor/wheels/controllers/Tests.cfc"))).toBeFalse( |
| 165 | + "Unrouted Tests.cfc is not on the ##3083 allowlisted runners; delete it rather than leave an orphan." |
| 166 | + ); |
| 167 | + }); |
| 168 | + |
| 169 | + it("allowlisted runners route to Public.cfc, not a Tests controller", () => { |
| 170 | + var publicRoutes = fileRead(expandPath("/vendor/wheels/public/routes.cfm")); |
| 171 | + var testRoutes = fileRead(expandPath("/vendor/wheels/tests/routes.cfm")); |
| 172 | + expect(publicRoutes).toInclude("public####tests_testbox"); |
| 173 | + expect(publicRoutes).toInclude("wheels####public####testbox"); |
| 174 | + expect(reFindNoCase("to\s*=\s*""Tests####", publicRoutes)).toBe(0); |
| 175 | + expect(reFindNoCase("to\s*=\s*""Tests####", testRoutes)).toBe(0); |
| 176 | + }); |
| 177 | + |
| 178 | + }); |
| 179 | + |
| 180 | + } |
| 181 | + |
| 182 | +} |
0 commit comments