Skip to content

Commit 5e11c77

Browse files
committed
1 parent cf16fcb commit 5e11c77

File tree

5 files changed

+48
-32
lines changed

5 files changed

+48
-32
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from 'node:assert';
2-
import { value, asyncValue } from './dist/lib/entries/a.js';
3-
import { value as value2, asyncValue as asyncValue2 } from './dist/lib/entries/b.js';
2+
import { value, asyncValue } from './dist/lib/entries/a.mjs';
3+
import { value as value2, asyncValue as asyncValue2 } from './dist/lib/entries/b.mjs';
44

55
assert.strictEqual(value, value2);
66
assert.strictEqual(await asyncValue, await asyncValue2);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from 'node:assert';
2-
import { value, asyncValue } from './dist/entries/a.js';
3-
import { value as value2, asyncValue as asyncValue2 } from './dist/entries/b.js';
2+
import { value, asyncValue } from './dist/entries/a.mjs';
3+
import { value as value2, asyncValue as asyncValue2 } from './dist/entries/b.mjs';
44

55
assert.strictEqual(value, value2);
66
assert.strictEqual(await asyncValue, await asyncValue2);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'node:test';
1+
import assert from 'node:assert';
22
import { b } from './dist/a/index.js';
33

44
assert.strictEqual(b, 2, 'b should be 2');
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
const require = (await import('node:module')).createRequire(import.meta.url);
2-
const fs = require('node:fs');
3-
const assert = require('node:assert');
4-
const path = require('node:path');
1+
import fs from 'node:fs';
2+
import assert from 'node:assert';
3+
import path from 'node:path';
54

6-
const source = fs.readFileSync(path.resolve(__dirname, 'dist/assets/main.js'), 'utf8');
5+
const source = fs.readFileSync(path.resolve(import.meta.dirname, 'dist/assets/main.js'), 'utf8');
76
const match = source.match(/\/\/# debugId=([a-fA-F0-9-]+)/);
87

98
assert.ok(match, 'Could not find debugId in source');
109
const sourceDebugId = match[1];
1110

1211
const sourceMap = JSON.parse(
13-
fs.readFileSync(path.resolve(__dirname, 'dist/assets/main.js.map'), 'utf8'),
12+
fs.readFileSync(path.resolve(import.meta.dirname, 'dist/assets/main.js.map'), 'utf8'),
1413
);
1514
assert.equal(sourceMap.debugId, sourceDebugId, 'debugId mismatch');

crates/rolldown_testing/src/integration_test.rs

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -324,20 +324,33 @@ impl IntegrationTest {
324324

325325
// Execute output if needed
326326
let bundler_options = dev_engine.bundler_options().await;
327+
let config_name = named_options
328+
.config_name
329+
.as_deref()
330+
.map(Some)
331+
.unwrap_or(self.test_meta.config_name.as_deref());
327332
if self.should_execute_output() {
328333
Self::execute_output_assets(
329334
&bundler_options,
330335
&debug_title,
331336
&patch_chunks,
332-
named_options
333-
.config_name
334-
.as_deref()
335-
.map(Some)
336-
.unwrap_or(self.test_meta.config_name.as_deref()),
337+
config_name,
338+
true,
337339
);
338-
} else if !self.test_meta.skip_syntax_validation {
339-
// When not executing output, validate that all JS chunks are syntactically valid
340-
Self::validate_output_chunks_syntax(output, &bundler_options);
340+
} else {
341+
if self.test_meta.write_to_disk {
342+
Self::execute_output_assets(
343+
&bundler_options,
344+
&debug_title,
345+
&patch_chunks,
346+
config_name,
347+
false,
348+
);
349+
}
350+
if !self.test_meta.skip_syntax_validation {
351+
// When not executing output, validate that all JS chunks are syntactically valid
352+
Self::validate_output_chunks_syntax(output, &bundler_options);
353+
}
341354
}
342355
}
343356
Err(errs) => {
@@ -414,20 +427,21 @@ impl IntegrationTest {
414427
!self.test_meta.expect_error,
415428
"Expected the bundling to be failed with diagnosable errors, but got success"
416429
);
430+
let config_name = named_options
431+
.config_name
432+
.as_deref()
433+
.map(Some)
434+
.unwrap_or(self.test_meta.config_name.as_deref());
417435
if self.should_execute_output() {
418-
Self::execute_output_assets(
419-
bundler.options(),
420-
&debug_title,
421-
&[],
422-
named_options
423-
.config_name
424-
.as_deref()
425-
.map(Some)
426-
.unwrap_or(self.test_meta.config_name.as_deref()),
427-
);
428-
} else if !self.test_meta.skip_syntax_validation {
429-
// When not executing output, validate that all JS chunks are syntactically valid
430-
Self::validate_output_chunks_syntax(output, bundler.options());
436+
Self::execute_output_assets(bundler.options(), &debug_title, &[], config_name, true);
437+
} else {
438+
if self.test_meta.write_to_disk {
439+
Self::execute_output_assets(bundler.options(), &debug_title, &[], config_name, false);
440+
}
441+
if !self.test_meta.skip_syntax_validation {
442+
// When not executing output, validate that all JS chunks are syntactically valid
443+
Self::validate_output_chunks_syntax(output, bundler.options());
444+
}
431445
}
432446
}
433447
Err(errs) => {
@@ -554,6 +568,7 @@ impl IntegrationTest {
554568
test_title: &str,
555569
patch_chunks: &[String],
556570
config_name: Option<&str>,
571+
execute_compiled_entries: bool,
557572
) {
558573
let cwd = options.cwd.clone();
559574
let dist_folder = cwd.join(&options.out_dir);
@@ -597,6 +612,8 @@ impl IntegrationTest {
597612

598613
if test_script.exists() {
599614
node_command.arg(test_script);
615+
} else if !execute_compiled_entries {
616+
return;
600617
} else {
601618
// make sure to set this: https://github.com/nodejs/node/issues/59374
602619
node_command.arg("--input-type=module");

0 commit comments

Comments
 (0)