@telorun/test 0.4.34 → 0.4.36

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/dist/suite.js CHANGED
@@ -110,23 +110,25 @@ function parseEnvFile(content) {
110
110
  }
111
111
  /**
112
112
  * Loads .env and .env.local files (in that order) from the directory of
113
- * the manifest, layered under (and overridden by) process.env.
113
+ * the manifest, layered under (and overridden by) the host environment.
114
114
  *
115
- * Keys already present in process.env take precedence (same as CLI behaviour).
115
+ * `hostEnv` is the suite controller's `ctx.env` (the sanctioned host-env
116
+ * snapshot) — not the locked `process.env` — and takes precedence over the
117
+ * .env files, matching CLI behaviour.
116
118
  */
117
- function buildEnvForManifest(manifestPath) {
119
+ function buildEnvForManifest(manifestPath, hostEnv) {
118
120
  const dir = path.dirname(path.resolve(manifestPath));
119
121
  const base = parseEnvFile(tryReadFile(path.join(dir, ".env")));
120
122
  const local = parseEnvFile(tryReadFile(path.join(dir, ".env.local")));
121
- return { ...base, ...local, ...process.env };
123
+ return { ...base, ...local, ...hostEnv };
122
124
  }
123
- async function runOneTest(testPath, captureOutput, parentStdout, parentStderr) {
125
+ async function runOneTest(testPath, captureOutput, parentStdout, parentStderr, hostEnv) {
124
126
  const start = Date.now();
125
127
  const stdout = captureOutput ? new BufferedWritable() : parentStdout;
126
128
  const stderr = captureOutput ? new BufferedWritable() : parentStderr;
127
129
  try {
128
130
  const kernel = new Kernel({
129
- env: buildEnvForManifest(testPath),
131
+ env: buildEnvForManifest(testPath, hostEnv),
130
132
  stdout,
131
133
  stderr,
132
134
  sources: [new LocalFileSource()],
@@ -180,7 +182,7 @@ export async function create(manifest, ctx) {
180
182
  return;
181
183
  const testPath = tests[i];
182
184
  const label = labelFor(testPath, baseDir);
183
- const result = await runOneTest(testPath, !singleTest, ctx.stdout, ctx.stderr);
185
+ const result = await runOneTest(testPath, !singleTest, ctx.stdout, ctx.stderr, ctx.env);
184
186
  result.label = label;
185
187
  results.push(result);
186
188
  if (result.passed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/test",
3
- "version": "0.4.34",
3
+ "version": "0.4.36",
4
4
  "description": "Telo Test module - Test runner for Telo manifests.",
5
5
  "keywords": [
6
6
  "telo",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@sinclair/typebox": "^0.34.48",
36
36
  "@telorun/glob": "0.2.0",
37
- "@telorun/kernel": "0.39.1"
37
+ "@telorun/kernel": "0.40.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^20.0.0",
package/src/suite.ts CHANGED
@@ -140,15 +140,20 @@ function parseEnvFile(content: string | null): Record<string, string> {
140
140
 
141
141
  /**
142
142
  * Loads .env and .env.local files (in that order) from the directory of
143
- * the manifest, layered under (and overridden by) process.env.
143
+ * the manifest, layered under (and overridden by) the host environment.
144
144
  *
145
- * Keys already present in process.env take precedence (same as CLI behaviour).
145
+ * `hostEnv` is the suite controller's `ctx.env` (the sanctioned host-env
146
+ * snapshot) — not the locked `process.env` — and takes precedence over the
147
+ * .env files, matching CLI behaviour.
146
148
  */
147
- function buildEnvForManifest(manifestPath: string): Record<string, string | undefined> {
149
+ function buildEnvForManifest(
150
+ manifestPath: string,
151
+ hostEnv: Record<string, string | undefined>,
152
+ ): Record<string, string | undefined> {
148
153
  const dir = path.dirname(path.resolve(manifestPath));
149
154
  const base = parseEnvFile(tryReadFile(path.join(dir, ".env")));
150
155
  const local = parseEnvFile(tryReadFile(path.join(dir, ".env.local")));
151
- return { ...base, ...local, ...process.env };
156
+ return { ...base, ...local, ...hostEnv };
152
157
  }
153
158
 
154
159
  async function runOneTest(
@@ -156,13 +161,14 @@ async function runOneTest(
156
161
  captureOutput: boolean,
157
162
  parentStdout: NodeJS.WritableStream,
158
163
  parentStderr: NodeJS.WritableStream,
164
+ hostEnv: Record<string, string | undefined>,
159
165
  ): Promise<TestResult> {
160
166
  const start = Date.now();
161
167
  const stdout = captureOutput ? new BufferedWritable() : parentStdout;
162
168
  const stderr = captureOutput ? new BufferedWritable() : parentStderr;
163
169
  try {
164
170
  const kernel = new Kernel({
165
- env: buildEnvForManifest(testPath),
171
+ env: buildEnvForManifest(testPath, hostEnv),
166
172
  stdout,
167
173
  stderr,
168
174
  sources: [new LocalFileSource()],
@@ -225,7 +231,7 @@ export async function create(
225
231
  if (i >= tests.length) return;
226
232
  const testPath = tests[i];
227
233
  const label = labelFor(testPath, baseDir);
228
- const result = await runOneTest(testPath, !singleTest, ctx.stdout, ctx.stderr);
234
+ const result = await runOneTest(testPath, !singleTest, ctx.stdout, ctx.stderr, ctx.env);
229
235
  result.label = label;
230
236
  results.push(result);
231
237