|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 |
|
3 | 3 | import { |
| 4 | + assertVersionConsistency, |
4 | 5 | NIGHTLY_VERSION_ENV, |
5 | 6 | OUT_DIRS, |
6 | 7 | resolveBuildTarget, |
@@ -64,6 +65,61 @@ describe("the version a build reports as its own", () => { |
64 | 65 | }); |
65 | 66 | }); |
66 | 67 |
|
| 68 | +// #148 post-mortem. The two defines were DERIVED from one stamp but never |
| 69 | +// CHECKED against each other, so a single artifact announced one version and |
| 70 | +// sent every agent to another, silently. These pin the guard that makes that |
| 71 | +// state unbuildable rather than merely unlikely. |
| 72 | +describe("a build must agree with itself about its version", () => { |
| 73 | + it("refuses a nightly whose invocation names a different version", () => { |
| 74 | + expect(() => |
| 75 | + assertVersionConsistency( |
| 76 | + nightlyEnvironment, |
| 77 | + "0.10.2", |
| 78 | + `npx @taskless/cli-nightly@${NIGHTLY_VERSION}` |
| 79 | + ) |
| 80 | + ).toThrow(/inconsistent with itself/); |
| 81 | + }); |
| 82 | + |
| 83 | + // The exact shape of the shipped bug, named in the message so whoever hits |
| 84 | + // this next has the history rather than just the assertion. |
| 85 | + it("names the issue and the env var both values derive from", () => { |
| 86 | + expect(() => |
| 87 | + assertVersionConsistency( |
| 88 | + nightlyEnvironment, |
| 89 | + "0.10.2", |
| 90 | + `npx @taskless/cli-nightly@${NIGHTLY_VERSION}` |
| 91 | + ) |
| 92 | + ).toThrow(new RegExp(String.raw`148[\s\S]*` + NIGHTLY_VERSION_ENV)); |
| 93 | + }); |
| 94 | + |
| 95 | + it("accepts a nightly whose two values agree", () => { |
| 96 | + expect(() => |
| 97 | + assertVersionConsistency( |
| 98 | + nightlyEnvironment, |
| 99 | + NIGHTLY_VERSION, |
| 100 | + `npx @taskless/cli-nightly@${NIGHTLY_VERSION}` |
| 101 | + ) |
| 102 | + ).not.toThrow(); |
| 103 | + }); |
| 104 | + |
| 105 | + // A version pin is meaningless for the other targets: prod names a floating |
| 106 | + // package deliberately, and dev/self name a filesystem path. Asserting there |
| 107 | + // would fail every ordinary build. |
| 108 | + it.each([ |
| 109 | + ["prod", "npx @taskless/cli"], |
| 110 | + ["dev", "node /repo/packages/cli/dist-dev/index.js"], |
| 111 | + ["self", "node packages/cli/dist-self/index.js"], |
| 112 | + ])("does not constrain the %s target", (target, invocation) => { |
| 113 | + expect(() => |
| 114 | + assertVersionConsistency( |
| 115 | + { TASKLESS_BUILD_TARGET: target }, |
| 116 | + "0.10.2", |
| 117 | + invocation |
| 118 | + ) |
| 119 | + ).not.toThrow(); |
| 120 | + }); |
| 121 | +}); |
| 122 | + |
67 | 123 | describe("the nightly target", () => { |
68 | 124 | // The whole point of the target: a nightly's skills, commands, and recipes |
69 | 125 | // must send an agent to the package the reader installed. Without the |
|
0 commit comments