@agiledigital/pingone-aic-script-tester 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +274 -0
- package/dist/bin/fetch-jar.d.ts +2 -0
- package/dist/bin/fetch-jar.js +13 -0
- package/dist/bin/pull-profile.d.ts +2 -0
- package/dist/bin/pull-profile.js +40 -0
- package/dist/bin/show-log.d.ts +2 -0
- package/dist/bin/show-log.js +31 -0
- package/dist/classes/.complete +12 -0
- package/dist/classes/AmClassShutter.class +0 -0
- package/dist/classes/AmContextFactory$ObservedContext.class +0 -0
- package/dist/classes/AmContextFactory.class +0 -0
- package/dist/classes/AmScopes.class +0 -0
- package/dist/classes/HostOps.class +0 -0
- package/dist/classes/JsValues.class +0 -0
- package/dist/classes/Json$Parser.class +0 -0
- package/dist/classes/Json.class +0 -0
- package/dist/classes/LanguageVersions.class +0 -0
- package/dist/classes/Runner.class +0 -0
- package/dist/classes/ScriptContextScope.class +0 -0
- package/dist/src/aic/callbacks.d.ts +35 -0
- package/dist/src/aic/callbacks.js +130 -0
- package/dist/src/aic/conform.d.ts +90 -0
- package/dist/src/aic/conform.js +193 -0
- package/dist/src/aic/constants.d.ts +13 -0
- package/dist/src/aic/constants.js +13 -0
- package/dist/src/aic/diff.d.ts +25 -0
- package/dist/src/aic/diff.js +201 -0
- package/dist/src/aic/emit-journey.d.ts +64 -0
- package/dist/src/aic/emit-journey.js +254 -0
- package/dist/src/aic/emit-result.d.ts +10 -0
- package/dist/src/aic/emit-result.js +39 -0
- package/dist/src/aic/emit-session.d.ts +26 -0
- package/dist/src/aic/emit-session.js +132 -0
- package/dist/src/aic/emit-subject.d.ts +40 -0
- package/dist/src/aic/emit-subject.js +210 -0
- package/dist/src/aic/file-lease.d.ts +35 -0
- package/dist/src/aic/file-lease.js +543 -0
- package/dist/src/aic/http.d.ts +21 -0
- package/dist/src/aic/http.js +127 -0
- package/dist/src/aic/idm.d.ts +10 -0
- package/dist/src/aic/idm.js +112 -0
- package/dist/src/aic/index.d.ts +35 -0
- package/dist/src/aic/index.js +21 -0
- package/dist/src/aic/js.d.ts +8 -0
- package/dist/src/aic/js.js +11 -0
- package/dist/src/aic/lease-identity.d.ts +38 -0
- package/dist/src/aic/lease-identity.js +72 -0
- package/dist/src/aic/lease-lock.d.ts +45 -0
- package/dist/src/aic/lease-lock.js +173 -0
- package/dist/src/aic/managed.d.ts +28 -0
- package/dist/src/aic/managed.js +199 -0
- package/dist/src/aic/provider.d.ts +156 -0
- package/dist/src/aic/provider.js +416 -0
- package/dist/src/aic/record.d.ts +28 -0
- package/dist/src/aic/record.js +183 -0
- package/dist/src/aic/resource-snapshot.d.ts +12 -0
- package/dist/src/aic/resource-snapshot.js +116 -0
- package/dist/src/aic/run.d.ts +102 -0
- package/dist/src/aic/run.js +450 -0
- package/dist/src/aic/tenant.d.ts +107 -0
- package/dist/src/aic/tenant.js +307 -0
- package/dist/src/aic/trace.d.ts +25 -0
- package/dist/src/aic/trace.js +56 -0
- package/dist/src/aic/txid.d.ts +11 -0
- package/dist/src/aic/txid.js +25 -0
- package/dist/src/aic/unsupported.d.ts +15 -0
- package/dist/src/aic/unsupported.js +60 -0
- package/dist/src/bindings/allowlist.d.ts +42 -0
- package/dist/src/bindings/allowlist.js +62 -0
- package/dist/src/bindings/harvest.d.ts +7 -0
- package/dist/src/bindings/harvest.js +137 -0
- package/dist/src/bindings/index.d.ts +4 -0
- package/dist/src/bindings/index.js +3 -0
- package/dist/src/bindings/preamble.d.ts +23 -0
- package/dist/src/bindings/preamble.js +36 -0
- package/dist/src/bindings/run.d.ts +33 -0
- package/dist/src/bindings/run.js +55 -0
- package/dist/src/case/equal.d.ts +2 -0
- package/dist/src/case/equal.js +40 -0
- package/dist/src/case/index.d.ts +5 -0
- package/dist/src/case/index.js +4 -0
- package/dist/src/case/portable.d.ts +10 -0
- package/dist/src/case/portable.js +28 -0
- package/dist/src/case/session.d.ts +34 -0
- package/dist/src/case/session.js +66 -0
- package/dist/src/case/state.d.ts +4 -0
- package/dist/src/case/state.js +47 -0
- package/dist/src/case/types.d.ts +266 -0
- package/dist/src/case/types.js +106 -0
- package/dist/src/case/util.d.ts +7 -0
- package/dist/src/case/util.js +115 -0
- package/dist/src/case/validate.d.ts +8 -0
- package/dist/src/case/validate.js +463 -0
- package/dist/src/case/verdict.d.ts +6 -0
- package/dist/src/case/verdict.js +810 -0
- package/dist/src/diagnostics.d.ts +7 -0
- package/dist/src/diagnostics.js +5 -0
- package/dist/src/emit-dts.d.ts +2 -0
- package/dist/src/emit-dts.js +82 -0
- package/dist/src/emit-js.d.ts +3 -0
- package/dist/src/emit-js.js +149 -0
- package/dist/src/harness/failures.d.ts +26 -0
- package/dist/src/harness/failures.js +113 -0
- package/dist/src/harness/idm.d.ts +12 -0
- package/dist/src/harness/idm.js +44 -0
- package/dist/src/harness/index.d.ts +11 -0
- package/dist/src/harness/index.js +6 -0
- package/dist/src/harness/lease.d.ts +136 -0
- package/dist/src/harness/lease.js +286 -0
- package/dist/src/harness/residue.d.ts +23 -0
- package/dist/src/harness/residue.js +73 -0
- package/dist/src/harness/show-log.d.ts +43 -0
- package/dist/src/harness/show-log.js +253 -0
- package/dist/src/harness/spec.d.ts +67 -0
- package/dist/src/harness/spec.js +189 -0
- package/dist/src/harness/step.d.ts +80 -0
- package/dist/src/harness/step.js +97 -0
- package/dist/src/harness/types.d.ts +100 -0
- package/dist/src/harness/types.js +1 -0
- package/dist/src/harness/vitest.d.ts +52 -0
- package/dist/src/harness/vitest.js +155 -0
- package/dist/src/idents.d.ts +4 -0
- package/dist/src/idents.js +42 -0
- package/dist/src/jvm.d.ts +124 -0
- package/dist/src/jvm.js +432 -0
- package/dist/src/load.d.ts +2 -0
- package/dist/src/load.js +104 -0
- package/dist/src/paths.d.ts +36 -0
- package/dist/src/paths.js +50 -0
- package/dist/src/profile/index.d.ts +5 -0
- package/dist/src/profile/index.js +3 -0
- package/dist/src/profile/normalise.d.ts +16 -0
- package/dist/src/profile/normalise.js +106 -0
- package/dist/src/profile/pull.d.ts +22 -0
- package/dist/src/profile/pull.js +36 -0
- package/dist/src/profile/seed.d.ts +11 -0
- package/dist/src/profile/seed.js +28 -0
- package/dist/src/profile/store.d.ts +13 -0
- package/dist/src/profile/store.js +60 -0
- package/dist/src/profile/types.d.ts +45 -0
- package/dist/src/profile/types.js +1 -0
- package/dist/src/profile/validate.d.ts +38 -0
- package/dist/src/profile/validate.js +129 -0
- package/dist/src/project.d.ts +37 -0
- package/dist/src/project.js +93 -0
- package/dist/src/protocol.d.ts +62 -0
- package/dist/src/protocol.js +68 -0
- package/dist/src/provider-module.d.ts +11 -0
- package/dist/src/provider-module.js +46 -0
- package/dist/src/runner.d.ts +39 -0
- package/dist/src/runner.js +337 -0
- package/dist/src/schema.d.ts +48 -0
- package/dist/src/schema.js +93 -0
- package/generated/scripted-decision-mocks.cjs +722 -0
- package/generated/scripted-decision-mocks.d.ts +626 -0
- package/generated/scripted-decision-next.json +3640 -0
- package/java/AmClassShutter.java +98 -0
- package/java/AmContextFactory.java +69 -0
- package/java/AmScopes.java +49 -0
- package/java/HostOps.java +180 -0
- package/java/JsValues.java +39 -0
- package/java/Json.java +441 -0
- package/java/LanguageVersions.java +55 -0
- package/java/Runner.java +289 -0
- package/java/ScriptContextScope.java +147 -0
- package/package.json +88 -0
- package/src/bindings/rhino/runtime.cjs +3021 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { afterAll, afterEach, beforeAll, beforeEach, expect } from "vitest";
|
|
3
|
+
import { AicFileLease } from "../aic/file-lease.js";
|
|
4
|
+
import { chainFromRunResult } from "../aic/conform.js";
|
|
5
|
+
import { clearAicTrace, takeAicTrace } from "../aic/trace.js";
|
|
6
|
+
import { projectRoot } from "../project.js";
|
|
7
|
+
import { RhinoRunner } from "../runner.js";
|
|
8
|
+
import { recordFailureIfAny } from "./failures.js";
|
|
9
|
+
import { Lease, } from "./lease.js";
|
|
10
|
+
/** The env var that opts a run into the tenant lane. */
|
|
11
|
+
export const AIC_LANE_ENV = "AIC_SCRIPT_TESTER_AIC";
|
|
12
|
+
/**
|
|
13
|
+
* Spread into `useLease` options to run both lanes when `AIC_SCRIPT_TESTER_AIC=1`.
|
|
14
|
+
*
|
|
15
|
+
* Off by default, deliberately. The tenant lane needs an unlocked agent and
|
|
16
|
+
* network, which CI has neither of, and a checkout without them should still
|
|
17
|
+
* be able to run the whole suite offline — so opting in is a per-invocation
|
|
18
|
+
* decision, not a property of the file:
|
|
19
|
+
*
|
|
20
|
+
* npm test # local lane only, as before
|
|
21
|
+
* AIC_SCRIPT_TESTER_AIC=1 npm test # both lanes, against the sandbox
|
|
22
|
+
*
|
|
23
|
+
* `id` must be unique per file: it seeds the deterministic resource ids, and
|
|
24
|
+
* one AIC lease per file is enforced.
|
|
25
|
+
*/
|
|
26
|
+
export function aicWhenEnabled(id, realm = "alpha") {
|
|
27
|
+
return process.env[AIC_LANE_ENV] === "1" ? { aic: { id, realm } } : {};
|
|
28
|
+
}
|
|
29
|
+
const aicLeaseByFile = new Map();
|
|
30
|
+
/**
|
|
31
|
+
* Take a lease for one test file, and register its own lifecycle.
|
|
32
|
+
*
|
|
33
|
+
* The hooks are registered here rather than left to the author because
|
|
34
|
+
* forgetting teardown is the one mistake that leaks tenant state, and it
|
|
35
|
+
* leaks silently — the suite still passes. Owning the hooks makes the leak
|
|
36
|
+
* impossible to cause by omission. The same applies to failure records: the
|
|
37
|
+
* author must not have to remember to write the transaction id down.
|
|
38
|
+
*/
|
|
39
|
+
export function useLease(suite, options = {}) {
|
|
40
|
+
let runner;
|
|
41
|
+
let aicLease;
|
|
42
|
+
const lane = options.aic === undefined
|
|
43
|
+
? undefined
|
|
44
|
+
: {
|
|
45
|
+
run: ({ result, source, hooks }) => {
|
|
46
|
+
if (aicLease === undefined) {
|
|
47
|
+
throw new Error("rhino-local: AIC lease used before beforeAll completed");
|
|
48
|
+
}
|
|
49
|
+
return aicLease.run({ ...chainFromRunResult(result), source, hooks });
|
|
50
|
+
},
|
|
51
|
+
endTest: () => aicLease?.endTest() ?? Promise.resolve(),
|
|
52
|
+
};
|
|
53
|
+
const lease = new Lease(suite.spec, {
|
|
54
|
+
get runner() {
|
|
55
|
+
if (runner === undefined) {
|
|
56
|
+
throw new Error("rhino-local: lease used before beforeAll ran — call useLease() at describe scope, not inside a test");
|
|
57
|
+
}
|
|
58
|
+
return runner;
|
|
59
|
+
},
|
|
60
|
+
...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),
|
|
61
|
+
...(options.allowResidue !== undefined ? { allowResidue: options.allowResidue } : {}),
|
|
62
|
+
...(lane === undefined ? {} : { lane }),
|
|
63
|
+
...(options.aic === undefined ? {} : { realm: options.aic.realm ?? "alpha" }),
|
|
64
|
+
testName: () => expect.getState().currentTestName ?? suite.spec.name,
|
|
65
|
+
});
|
|
66
|
+
// Vitest 5 requires fixture destructuring before the suite argument.
|
|
67
|
+
// eslint-disable-next-line no-empty-pattern
|
|
68
|
+
beforeAll(async ({}, scope) => {
|
|
69
|
+
runner = await RhinoRunner.spawn();
|
|
70
|
+
lease.open();
|
|
71
|
+
if (options.aic !== undefined) {
|
|
72
|
+
claimAicLeaseForFile(vitestFilePath(scope), options.aic.id);
|
|
73
|
+
aicLease = new AicFileLease({
|
|
74
|
+
id: options.aic.id,
|
|
75
|
+
suiteName: suite.spec.name,
|
|
76
|
+
source: suite.spec.script,
|
|
77
|
+
outcomes: suite.spec.outcomes,
|
|
78
|
+
...(options.aic.realm === undefined ? {} : { realm: options.aic.realm }),
|
|
79
|
+
...(options.aic.tenant === undefined ? {} : { tenant: options.aic.tenant }),
|
|
80
|
+
...(options.aic.project === undefined ? {} : { project: options.aic.project }),
|
|
81
|
+
...(options.aic.provider === undefined ? {} : { provider: options.aic.provider }),
|
|
82
|
+
...(options.aic.unsupported === undefined
|
|
83
|
+
? {}
|
|
84
|
+
: { unsupported: options.aic.unsupported }),
|
|
85
|
+
...(options.aicIo === undefined ? {} : { io: options.aicIo }),
|
|
86
|
+
...(options.aicStateDir === undefined
|
|
87
|
+
? {}
|
|
88
|
+
: { stateDir: options.aicStateDir }),
|
|
89
|
+
});
|
|
90
|
+
await aicLease.open();
|
|
91
|
+
}
|
|
92
|
+
}, options.spawnTimeoutMs ?? 60_000);
|
|
93
|
+
beforeEach((context) => {
|
|
94
|
+
clearAicTrace();
|
|
95
|
+
context.onTestFailed(async () => {
|
|
96
|
+
const trace = takeAicTrace();
|
|
97
|
+
try {
|
|
98
|
+
await recordFailureIfAny({
|
|
99
|
+
trace,
|
|
100
|
+
testName: expect.getState().currentTestName ?? context.task.name,
|
|
101
|
+
file: relative(projectRoot(), context.task.file.filepath),
|
|
102
|
+
suite: suite.spec.name,
|
|
103
|
+
timestamp: new Date().toISOString(),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
108
|
+
process.emitWarning(`rhino-local: could not record failure for show-log: ${message}`);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
afterEach(async () => {
|
|
113
|
+
await lease.endTest();
|
|
114
|
+
});
|
|
115
|
+
afterAll(async () => {
|
|
116
|
+
const errors = [];
|
|
117
|
+
try {
|
|
118
|
+
await aicLease?.close();
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
errors.push(error);
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
await lease.close();
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
errors.push(error);
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
await runner?.close();
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
errors.push(error);
|
|
134
|
+
}
|
|
135
|
+
if (errors.length > 0) {
|
|
136
|
+
throw new AggregateError(errors, "rhino-local lease teardown failed");
|
|
137
|
+
}
|
|
138
|
+
}, 30_000);
|
|
139
|
+
return lease;
|
|
140
|
+
}
|
|
141
|
+
export function claimAicLeaseForFile(file, id) {
|
|
142
|
+
const existing = aicLeaseByFile.get(file);
|
|
143
|
+
if (existing !== undefined) {
|
|
144
|
+
throw new Error(`rhino-local: test file already has AIC lease ${JSON.stringify(existing)}; split ${JSON.stringify(id)} into another file`);
|
|
145
|
+
}
|
|
146
|
+
aicLeaseByFile.set(file, id);
|
|
147
|
+
}
|
|
148
|
+
export function releaseAicLeaseForFile(file, id) {
|
|
149
|
+
if (id === undefined || aicLeaseByFile.get(file) === id) {
|
|
150
|
+
aicLeaseByFile.delete(file);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function vitestFilePath(scope) {
|
|
154
|
+
return "filepath" in scope ? scope.filepath : scope.file.filepath;
|
|
155
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
2
|
+
const TS_PARAM_RENAMES = {
|
|
3
|
+
arguments: "args",
|
|
4
|
+
};
|
|
5
|
+
export function assertIdent(name, what) {
|
|
6
|
+
if (!IDENT.test(name)) {
|
|
7
|
+
throw new Error(`rhino-local: ${what} is not a JS identifier: ${JSON.stringify(name)}`);
|
|
8
|
+
}
|
|
9
|
+
return name;
|
|
10
|
+
}
|
|
11
|
+
export function pascal(name) {
|
|
12
|
+
const ident = assertIdent(name, "type name");
|
|
13
|
+
const first = ident.charAt(0);
|
|
14
|
+
if (!first) {
|
|
15
|
+
throw new Error(`rhino-local: empty identifier`);
|
|
16
|
+
}
|
|
17
|
+
return first.toUpperCase() + ident.slice(1);
|
|
18
|
+
}
|
|
19
|
+
export function tsParamName(name) {
|
|
20
|
+
const renamed = TS_PARAM_RENAMES[name] ?? name;
|
|
21
|
+
return assertIdent(renamed, "parameter name");
|
|
22
|
+
}
|
|
23
|
+
export function tsType(jsType) {
|
|
24
|
+
switch (jsType) {
|
|
25
|
+
case "string":
|
|
26
|
+
return "string";
|
|
27
|
+
case "number":
|
|
28
|
+
return "number";
|
|
29
|
+
case "boolean":
|
|
30
|
+
return "boolean";
|
|
31
|
+
case "array":
|
|
32
|
+
return "unknown[]";
|
|
33
|
+
case "object":
|
|
34
|
+
return "object";
|
|
35
|
+
case "void":
|
|
36
|
+
return "void";
|
|
37
|
+
case "unknown":
|
|
38
|
+
return "unknown";
|
|
39
|
+
default:
|
|
40
|
+
throw new Error(`rhino-local: no TS mapping for javaScriptType ${jsType}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the runner's JVM comes from.
|
|
3
|
+
*
|
|
4
|
+
* - `host` — a Java 25 on this machine. The default: an 8GB laptop should not
|
|
5
|
+
* need the ~850MB AM image to run a unit test.
|
|
6
|
+
* - `container` — the JVM inside the AM image. The reference `host` is
|
|
7
|
+
* compared against; CI runs it, developers need not.
|
|
8
|
+
* - `both` — every job on both, failing on any difference. This is how the
|
|
9
|
+
* whole suite doubles as the host-vs-image conformance test.
|
|
10
|
+
*/
|
|
11
|
+
export type JvmLane = "host" | "container" | "both";
|
|
12
|
+
export declare const JVM_LANE_ENV = "AIC_SCRIPT_TESTER_JVM";
|
|
13
|
+
export declare function laneFromEnv(env?: NodeJS.ProcessEnv): JvmLane;
|
|
14
|
+
/**
|
|
15
|
+
* The Rhino AM 8.1.1 ships. MEASURED 2026-09-28: the jar in
|
|
16
|
+
* `WEB-INF/lib` of the AM image is byte-identical to this Maven Central
|
|
17
|
+
* artefact (same SHA-1 as the `.sha1` Central publishes), so there is no Ping
|
|
18
|
+
* code to extract and nothing about Rhino that needs the image.
|
|
19
|
+
*/
|
|
20
|
+
export declare const RHINO_JAR: {
|
|
21
|
+
readonly fileName: "rhino-1.7.14.1.jar";
|
|
22
|
+
readonly url: "https://repo1.maven.org/maven2/org/mozilla/rhino/1.7.14.1/rhino-1.7.14.1.jar";
|
|
23
|
+
readonly sha256: "407d4af6521494061d86b208e99804e0bf5c2fa38449c48f24b2f5a7154b4d8d";
|
|
24
|
+
readonly bytes: 1389188;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The AM image the `container` lane runs, pinned by digest so the reference
|
|
28
|
+
* cannot move under a re-pushed tag; override to calibrate another image.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEFAULT_AM_IMAGE: string;
|
|
31
|
+
/**
|
|
32
|
+
* The JVM AM runs, as the AM image reports it (MEASURED 2026-09-28):
|
|
33
|
+
* Temurin-25.0.4+7, `/etc/localtime` → `Etc/UTC`, `LANG=en_US.UTF-8`. The
|
|
34
|
+
* runner reports what it actually got at startup, and {@link checkEnvironment}
|
|
35
|
+
* refuses a JVM that differs in anything a script could observe.
|
|
36
|
+
*/
|
|
37
|
+
export declare const EXPECTED_ENVIRONMENT: {
|
|
38
|
+
readonly javaFeature: 25;
|
|
39
|
+
readonly timezone: "Etc/UTC";
|
|
40
|
+
readonly locale: "en-US";
|
|
41
|
+
readonly charset: "UTF-8";
|
|
42
|
+
readonly rhino: "Rhino 1.7.14.1";
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Flags for the host lane only. The properties pin what the AM image's JVM
|
|
46
|
+
* gets from its OS (UTC, en_US.UTF-8), which a host would otherwise take from
|
|
47
|
+
* its own settings. The heap cap, serial collector and C1-only JIT are what
|
|
48
|
+
* keep a runner small on an 8GB box.
|
|
49
|
+
*
|
|
50
|
+
* The container lane gets **none** of these: it is the reference, so it runs
|
|
51
|
+
* the image's JVM on the image's defaults, as the old launcher did. That makes
|
|
52
|
+
* `both` compare the constrained host against an unconstrained AM JVM, so a
|
|
53
|
+
* script that only works with more heap or a faster JIT shows up as a
|
|
54
|
+
* divergence rather than agreeing with itself.
|
|
55
|
+
*/
|
|
56
|
+
export declare const HOST_JVM_FLAGS: readonly string[];
|
|
57
|
+
export interface RunnerEnvironment {
|
|
58
|
+
javaFeature: number;
|
|
59
|
+
javaVersion: string;
|
|
60
|
+
javaVendorVersion: string | null;
|
|
61
|
+
timezone: string;
|
|
62
|
+
locale: string;
|
|
63
|
+
charset: string;
|
|
64
|
+
rhino: string;
|
|
65
|
+
}
|
|
66
|
+
export declare function parseEnvironment(readyLine: string): RunnerEnvironment;
|
|
67
|
+
/**
|
|
68
|
+
* Every field a script can observe must match AM's. The Java patch level and
|
|
69
|
+
* vendor are not checked here: they are what the `both` lane measures, and a
|
|
70
|
+
* developer's Temurin 25.0.4.1 is not wrong merely for not being 25.0.4.
|
|
71
|
+
*/
|
|
72
|
+
export declare function checkEnvironment(env: RunnerEnvironment, lane: "host" | "container"): void;
|
|
73
|
+
export declare const JAVA_HOME_ENV = "AIC_SCRIPT_TESTER_JAVA_HOME";
|
|
74
|
+
/** `bin/<tool>` under AIC_SCRIPT_TESTER_JAVA_HOME, then JAVA_HOME, else the bare name for PATH lookup. */
|
|
75
|
+
export declare function javaTool(tool: "java" | "javac", env?: NodeJS.ProcessEnv): string;
|
|
76
|
+
export declare function cacheDir(env?: NodeJS.ProcessEnv): string;
|
|
77
|
+
export type Fetcher = (url: string) => Promise<Uint8Array>;
|
|
78
|
+
/** A local copy of {@link RHINO_JAR} to use instead of the cache or a download. */
|
|
79
|
+
export declare const RHINO_JAR_ENV = "AIC_SCRIPT_TESTER_RHINO_JAR";
|
|
80
|
+
/**
|
|
81
|
+
* The Rhino jar, verified by SHA-256 every time it is used, not only when
|
|
82
|
+
* downloaded: a cache is a file anyone can overwrite, and a different Rhino
|
|
83
|
+
* would make every verdict in this harness a claim about the wrong engine.
|
|
84
|
+
*/
|
|
85
|
+
export declare function ensureRhinoJar(cache?: string, fetcher?: Fetcher, env?: NodeJS.ProcessEnv): Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* The runner classes to launch. First the package's prebuilt classes, when
|
|
88
|
+
* their manifest names these exact sources and every class still hashes as
|
|
89
|
+
* recorded — an installed package, which may have no `javac` at all. Otherwise
|
|
90
|
+
* classes compiled here, keyed by the Java sources, the compiler and the jar
|
|
91
|
+
* they compile against, so an edit to a `.java` file cannot run stale
|
|
92
|
+
* bytecode. Each compile goes to a scratch directory and is renamed to a
|
|
93
|
+
* **fresh** `<digest>-<uuid>` name, never to a shared one: Vitest spawns
|
|
94
|
+
* runners from several workers at once, and a name that is never reused
|
|
95
|
+
* cannot be replaced or moved after another worker has validated and returned
|
|
96
|
+
* it. Two cold workers may both publish; the copies are identical and the
|
|
97
|
+
* lowest valid name wins from then on.
|
|
98
|
+
*/
|
|
99
|
+
export declare function ensureRunnerClasses(jar: string, options?: {
|
|
100
|
+
cache?: string;
|
|
101
|
+
javac?: string;
|
|
102
|
+
sources?: string;
|
|
103
|
+
prebuilt?: string;
|
|
104
|
+
}): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Compile the classes a package ships (`npm run build`). Their manifest is
|
|
107
|
+
* keyed by the sources alone, not the compiler: the consumer running them has
|
|
108
|
+
* no `javac` to key by, and `--release` fixes the class-file target.
|
|
109
|
+
*/
|
|
110
|
+
export declare function buildPrebuiltClasses(options?: {
|
|
111
|
+
out?: string;
|
|
112
|
+
javac?: string;
|
|
113
|
+
sources?: string;
|
|
114
|
+
cache?: string;
|
|
115
|
+
}): Promise<string>;
|
|
116
|
+
export interface Launch {
|
|
117
|
+
command: string;
|
|
118
|
+
args: string[];
|
|
119
|
+
env: NodeJS.ProcessEnv;
|
|
120
|
+
/** Set for the container lane, so a crash can `docker rm -f` it. */
|
|
121
|
+
containerName?: string;
|
|
122
|
+
}
|
|
123
|
+
export declare function hostLaunch(classes: string, jar: string, env?: NodeJS.ProcessEnv): Launch;
|
|
124
|
+
export declare function containerLaunch(classes: string, jar: string, env?: NodeJS.ProcessEnv): Launch;
|