aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cli/run/run-quote.test.ts15
-rw-r--r--test/harness.ts2
2 files changed, 16 insertions, 1 deletions
diff --git a/test/cli/run/run-quote.test.ts b/test/cli/run/run-quote.test.ts
new file mode 100644
index 000000000..a6dffbd6a
--- /dev/null
+++ b/test/cli/run/run-quote.test.ts
@@ -0,0 +1,15 @@
+import { expect, it } from "bun:test";
+import { bunRunAsScript, tempDirWithFiles } from "harness";
+
+it("should handle quote escapes", () => {
+ const package_json = JSON.stringify({
+ scripts: {
+ test: `echo "test\\\\$(pwd)"`,
+ },
+ });
+ expect(package_json).toContain('\\"');
+ expect(package_json).toContain("\\\\");
+ const dir = tempDirWithFiles("run-quote", { "package.json": package_json });
+ const { stdout } = bunRunAsScript(dir, "test");
+ expect(stdout).toBe(`test\\${dir}`);
+});
diff --git a/test/harness.ts b/test/harness.ts
index bfd159b18..b0cedba74 100644
--- a/test/harness.ts
+++ b/test/harness.ts
@@ -81,7 +81,7 @@ export function hideFromStackTrace(block: CallableFunction) {
}
export function tempDirWithFiles(basename: string, files: Record<string, string>) {
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), basename + "_"));
+ const dir = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), basename + "_"));
for (const [name, contents] of Object.entries(files)) {
fs.writeFileSync(path.join(dir, name), contents);
}