Skip to content

Commit f74edc1

Browse files
committed
try tests with quarantine removal
1 parent c6e7075 commit f74edc1

File tree

1 file changed

+60
-12
lines changed

1 file changed

+60
-12
lines changed

binary/test/binary.test.ts

+60-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import FileSystemIde from "core/util/filesystem";
55
import { IMessenger } from "core/util/messenger";
66
import { ReverseMessageIde } from "core/util/reverseMessageIde";
77
import fs from "fs";
8-
import { ChildProcessWithoutNullStreams, spawn } from "node:child_process";
8+
import {
9+
ChildProcessWithoutNullStreams,
10+
execSync,
11+
spawn,
12+
} from "node:child_process";
913
import path from "path";
1014
import {
1115
CoreBinaryMessenger,
@@ -59,21 +63,65 @@ describe("Test Suite", () => {
5963

6064
beforeAll(async () => {
6165
const [platform, arch] = autodetectPlatformAndArch();
62-
const binaryPath = path.join(
63-
__dirname,
64-
"..",
65-
"bin",
66-
`${platform}-${arch}`,
67-
`continue-binary${platform === "win32" ? ".exe" : ""}`,
68-
);
69-
expect(fs.existsSync(binaryPath)).toBe(true);
66+
const binaryDir = path.join(__dirname, "..", "bin", `${platform}-${arch}`);
67+
const exe = platform === "win32" ? ".exe" : "";
68+
const binaryPath = path.join(binaryDir, `continue-binary${exe}`);
69+
const expectedItems = [
70+
`continue-binary${exe}`,
71+
`esbuild${exe}`,
72+
"index.node",
73+
"package.json",
74+
"build/Release/node_sqlite3.node",
75+
];
76+
expectedItems.forEach((item) => {
77+
expect(fs.existsSync(path.join(binaryDir, item))).toBe(true);
78+
});
79+
80+
// Set execute permissions and remove quarantine attribute if on macOS
81+
if (platform !== "win32") {
82+
try {
83+
fs.chmodSync(binaryPath, 0o755);
84+
console.log("Execute permissions set for the binary");
85+
86+
if (platform === "darwin") {
87+
const indexNodePath = path.join(binaryDir, "index.node");
88+
const filesToUnquarantine = [binaryPath, indexNodePath];
89+
90+
for (const file of filesToUnquarantine) {
91+
try {
92+
execSync(`xattr -d com.apple.quarantine "${file}"`, {
93+
stdio: "ignore",
94+
});
95+
console.log(
96+
`Quarantine attribute removed from ${path.basename(file)}`,
97+
);
98+
} catch (error) {
99+
console.warn(
100+
`Failed to remove quarantine attribute from ${path.basename(file)}:`,
101+
error,
102+
);
103+
}
104+
}
105+
}
106+
} catch (error) {
107+
console.error(
108+
"Error setting permissions or removing quarantine:",
109+
error,
110+
);
111+
}
112+
}
70113

71114
if (USE_TCP) {
72115
messenger = new CoreBinaryTcpMessenger<ToIdeProtocol, FromIdeProtocol>();
73116
} else {
74-
subprocess = spawn(binaryPath, {
75-
env: { ...process.env, CONTINUE_GLOBAL_DIR },
76-
});
117+
try {
118+
subprocess = spawn(binaryPath, {
119+
env: { ...process.env, CONTINUE_GLOBAL_DIR },
120+
});
121+
} catch (error) {
122+
console.error("Error spawning subprocess:", error);
123+
throw error;
124+
}
77125
messenger = new CoreBinaryMessenger<ToIdeProtocol, FromIdeProtocol>(
78126
subprocess,
79127
);

0 commit comments

Comments
 (0)