Skip to content

Commit

Permalink
test: add test case with double symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Feb 22, 2024
1 parent 4fa09eb commit 08db617
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion crates/swc_cli_impl/tests/issues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn cli() -> Result<Command> {

#[test]
fn issue_8265_1() -> Result<()> {
let pwd = Path::new("tests/fixture-manual/8265").canonicalize()?;
let pwd = Path::new("tests/fixture-manual/8265_1").canonicalize()?;
let tmp = TempDir::new()?;

create_dir_all(tmp.path().join("src/modules/moduleA"))?;
Expand Down Expand Up @@ -58,6 +58,64 @@ fn issue_8265_1() -> Result<()> {
Ok(())
}

#[test]
fn issue_8265_2() -> Result<()> {
let pwd = Path::new("tests/fixture-manual/8265_2").canonicalize()?;
let tmp = TempDir::new()?;
let sbx = &tmp.path().join("sbx/123")

create_dir_all(tmp.path().join("src/modules/moduleA"))?;
create_dir_all(tmp.path().join("src/modules/moduleB"))?;
create_dir_all(sbx.path().join("src/modules/moduleA"))?;
create_dir_all(sbx.path().join("src/modules/moduleB"))?;

hard_link(&pwd.join(".swcrc"), &tmp.path().join(".swcrc"));
hard_link(&pwd.join("src/index.ts"), &tmp.path().join("src/index.ts"));
hard_link(
&pwd.join("src/modules/moduleA/index.ts"),
&tmp.path().join("src/modules/moduleA/index.ts"),
);
hard_link(
&pwd.join("src/modules/moduleB/index.ts"),
&tmp.path().join("src/modules/moduleB/index.ts"),
);

symlink(&tmp.join(".swcrc"), &sbx.path().join(".swcrc"));
symlink(&tmp.join("src/index.ts"), &sbx.path().join("src/index.ts"));
symlink(
&tmp.join("src/modules/moduleA/index.ts"),
&sbx.path().join("src/modules/moduleA/index.ts"),
);
symlink(
&tmp.join("src/modules/moduleB/index.ts"),
&sbx.path().join("src/modules/moduleB/index.ts"),
);

print_ls_alr(&sbx);

let mut cmd = cli()?;
cmd.current_dir(&sbx)
.arg("compile")
.arg("--source-maps")
.arg("false")
.arg("--config-file")
.arg(".swcrc")
.arg("--out-file")
.arg("src/index.js")
.arg("src/index.ts");

cmd.assert().success();

let content = fs::read_to_string(sbx.join("src/index.js"))?;
assert!(
content.contains("require(\"./modules/moduleA\")"),
"{}",
content
);

Ok(())
}

#[test]
fn issue_8495_1() -> Result<()> {
let pwd = Path::new("tests/fixture-manual/8495").canonicalize()?;
Expand Down

0 comments on commit 08db617

Please sign in to comment.