Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 multi-declaration test #1070

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions crates/rolldown/tests/common/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ impl Fixture {

let output = command.output().unwrap();

#[allow(clippy::print_stdout)]
if !output.status.success() {
let stdout_utf8 = std::str::from_utf8(&output.stdout).unwrap();
let stderr_utf8 = std::str::from_utf8(&output.stderr).unwrap();

println!("⬇️⬇️ Failed to execute command ⬇️⬇️\n{command:?}\n⬆️⬆️ end ⬆️⬆️");
eprintln!("⬇️⬇️ Failed to execute command ⬇️⬇️\n{command:?}\n⬆️⬆️ end ⬆️⬆️");
panic!("⬇️⬇️ stderr ⬇️⬇️\n{stderr_utf8}\n⬇️⬇️ stdout ⬇️⬇️\n{stdout_utf8}\n⬆️⬆️ end ⬆️⬆️",);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"import": "entry.js"
}
]
}
}
},
"expectExecuted": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ input_file: crates/rolldown/tests/esbuild/dce/dce_template_literal
## entry_js.mjs

```js

// entry.js
let a = `${keep}`;
let c = `${keep ? 1 : 2n}`;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var remove;
var alsoKeep;
let a = `${keep}`
let b = `${123}`
let c = `${keep ? 1 : 2n}`
let d = `${remove ? 1 : 2n}`
let e = `${alsoKeep}`

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"import": "function3.js"
}
]
}
}
},
"expectExecuted": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/esbuild/dce/multiple_declaration_tree_shaking
---
# Assets

## function2_js.mjs

```js
// function2.js
function x() {
return 1;
}
console.log(x());
function x() {
return 2;
}
```
## function3_js.mjs

```js
// function3.js
function x() {
return 1;
}
console.log(x());
function x() {
return 2;
}
console.log(x());
function x() {
return 3;
}
```
## var2_js.mjs

```js
// var2.js
var x = 1;
console.log(x);
var x = 2;
```
## var3_js.mjs

```js
// var3.js
var x = 1;
console.log(x);
var x = 2;
console.log(x);
var x = 3;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/esbuild/dce/tree_shaking_no_bundle_cjs
---
# Assets

## entry_js.mjs

```js
// entry.js
function keep() {
}
keep();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/esbuild/dce/tree_shaking_no_bundle_esm
---
# Assets

## entry_js.mjs

```js
// entry.js
function keep() {
}
keep();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/esbuild/dce/tree_shaking_no_bundle_iife
---
# Assets

## entry_js.mjs

```js
// entry.js
function keep() {
}
keep();
```
9 changes: 8 additions & 1 deletion scripts/misc/gen-esbuild-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ import { URL } from 'node:url'
// 1. Set the test suite name.

/** @type {TestSuiteName} {@link suites} */
const SUITE_NAME = 'lower'
if (process.argv.length < 3) {
throw new Error("The length of arguments should not less than 3")
}


const SUITE_NAME = process.argv[2]

console.log(`SUITE_NAME: `, SUITE_NAME)

// 2. Set the tests root directory
const __dirname = fileURLToPath(new URL('.', import.meta.url))
Expand Down