Skip to content

Commit 5c44712

Browse files
committed
Fix Swift rpath lookup
1 parent 11db198 commit 5c44712

File tree

14 files changed

+85
-32
lines changed

14 files changed

+85
-32
lines changed

.vscode-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const launchArgs = [
3131
"--disable-crash-reporter",
3232
"--disable-workspace-trust",
3333
"--disable-telemetry",
34+
"--disable-extension",
35+
"vscode.github",
36+
"--disable-extension",
37+
"vscode.github-authentication",
3438
];
3539
if (dataDir) {
3640
launchArgs.push("--user-data-dir", dataDir);

docker/sandbox.sb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(deny default)
44

55
; Get fonts
6-
(import "system.sb")
6+
; (import "system.sb")
77

88
; Helpers
99
(define (param-regex param-name param-relative-regex)
@@ -50,18 +50,33 @@
5050
(regex #"^/private/var/folders/[^/]+/[^/]+/.+")
5151
(regex #"^/Library/Preferences/.*.plist")
5252
(regex #"^/[^/]+/Library/Python")
53+
(subpath "/Library/Developer/CommandLineTools")
5354
(subpath "/Library/Developer/Toolchains")
5455
(subpath "/Library/Frameworks/UIAutomation.framework")
5556
(subpath "/Library/Python")
57+
(subpath "/System/Library/Perl")
5658
(subpath "/Applications/Xcode.app")
5759
(subpath "/Applications/Xcode-beta.app")
5860
(subpath "/bin")
5961
(subpath "/usr/bin")
6062
(subpath "/usr/local/bin")
61-
(subpath "/usr/lib/swift")
6263
(subpath "/usr/libexec/path_helper")
6364
(subpath "/usr/local/share/git-core")
6465
(subpath "/usr/local/share/hwtrace")
66+
67+
(regex #".*/LLDB.framework/.*")
68+
(regex #".*/Python3.framework/.*")
69+
(regex #".*/branch-main/.*")
70+
(regex #".*/usr/lib/swift/.*")
71+
; (regex #".*/Frameworks/.*")
72+
; (regex #".*/PrivateFrameworks/.*")
73+
74+
; (subpath "/System/Volumes/Preboot")
75+
; (subpath "/System/Volumes")
76+
; (subpath "/usr/lib")
77+
; (subpath "/Users/ec2-user")
78+
; (subpath "/Library/Developer/CommandLineTool")
79+
; (subpath "/")
6580
)
6681

6782
(allow mach-lookup)
@@ -84,8 +99,11 @@
8499
(regex #"^/Users/[^/]+/Library/Caches/com.apple.python.*")
85100
(regex #"^/Users/[^/]+/Library/Developer/Xcode/DerivedData.*")
86101
(regex #"^/Users/[^/]+/Library/Application Support/Code.*")
102+
(regex #"^/Users/[^/]+/Library/Application Support/Microsoft.*")
87103
(regex #"^/private/var/folders/[^/]+/[^/]+/.+")
88104
(regex #"^/Users/[^/]+/.vscode.*")
105+
106+
(regex #".*/branch-main.*")
89107
)
90108

91109
; Execute

docker/test-macos.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ PATH="$ARTIFACTS/$NODE_NAME/bin:$PATH"
5656
mkdir -p "$(dirname "$VSCODE_SETTINGS")"
5757
cat <<EOT > "$VSCODE_SETTINGS"
5858
{
59-
"swift.disableSandbox": true
59+
"swift.path": "/Users/ec2-user/jenkins/workspace/pr-vscode-swift-macos/branch-main/latest_toolchain/usr/bin"
60+
"swift.disableSandbox": true,
61+
"swift.debugger.disable": true,
62+
"swift.debugger.path": "/Users/ec2-user/jenkins/workspace/pr-vscode-swift-macos/branch-main/latest_toolchain/usr/bin/lldb-dap",
63+
"lldb.library": "/Applications/Xcode-beta.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB",
64+
"lldb.launch.expressions": "native",
65+
"lldb.suppressUpdateNotifications": true
6066
}
6167
EOT
6268

@@ -84,4 +90,6 @@ export GIT_CONFIG_VALUE_0="$PWD/hooks"
8490

8591
# Need to set proxy to download VS Code
8692
export npm_config_https_proxy="$HTTPS_PROXY"
93+
94+
# export DEVELOPER_DIR=/Applications/Xcode-beta.app
8795
VSCODE_DATA_DIR="$USER_DATA" CI=1 FAST_TEST_RUN=1 npm run coverage -- --coverage-output "$PWD/coverage"

src/SwiftPackage.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,9 @@ export class SwiftPackage implements PackageContents {
211211
toolchain: SwiftToolchain
212212
): Promise<SwiftPackageState> {
213213
try {
214-
let { stdout } = await execSwift(
215-
toolchain.buildFlags.withAdditionalFlags(["package", "describe", "--type", "json"]),
216-
toolchain,
217-
{
218-
cwd: folder.fsPath,
219-
}
220-
);
214+
let { stdout } = await execSwift(["package", "describe", "--type", "json"], toolchain, {
215+
cwd: folder.fsPath,
216+
});
221217
// remove lines from `swift package describe` until we find a "{"
222218
while (!stdout.startsWith("{")) {
223219
const firstNewLine = stdout.indexOf("\n");

src/configuration.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export interface DebuggerConfiguration {
5151
readonly useDebugAdapterFromToolchain: boolean;
5252
/** Return path to debug adapter */
5353
readonly customDebugAdapterPath: string;
54+
/** Whether or not to disable setting up the debugger */
55+
readonly disable: boolean;
5456
}
5557

5658
/** workspace folder configuration */
@@ -199,6 +201,11 @@ const configuration = {
199201
get customDebugAdapterPath(): string {
200202
return vscode.workspace.getConfiguration("swift.debugger").get<string>("path", "");
201203
},
204+
get disable(): boolean {
205+
return vscode.workspace
206+
.getConfiguration("swift.debugger")
207+
.get<boolean>("disable", false);
208+
},
202209
};
203210
},
204211
/** Files and directories to exclude from the code coverage. */

src/extension.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { showReloadExtensionNotification } from "./ui/ReloadExtension";
3838
import { checkAndWarnAboutWindowsSymlinks } from "./ui/win32";
3939
import { SwiftEnvironmentVariablesManager, SwiftTerminalProfileProvider } from "./terminal";
4040
import { resolveFolderDependencies } from "./commands/dependencies/resolve";
41-
import { SelectedXcodeWatcher } from "./toolchain/SelectedXcodeWatcher";
41+
// import { SelectedXcodeWatcher } from "./toolchain/SelectedXcodeWatcher";
4242

4343
/**
4444
* External API as exposed by the extension. Can be queried by other extensions
@@ -128,8 +128,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<Api> {
128128
const workspaceContext = await WorkspaceContext.create(context, outputChannel, toolchain);
129129
context.subscriptions.push(...commands.register(workspaceContext));
130130
context.subscriptions.push(workspaceContext);
131-
context.subscriptions.push(registerDebugger(workspaceContext));
132-
context.subscriptions.push(new SelectedXcodeWatcher(outputChannel));
131+
if (!configuration.debugger.disable) {
132+
context.subscriptions.push(registerDebugger(workspaceContext));
133+
}
134+
// context.subscriptions.push(new SelectedXcodeWatcher(outputChannel));
133135

134136
// listen for workspace folder changes and active text editor changes
135137
workspaceContext.setupEventListeners();

src/toolchain/toolchain.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,7 @@ export class SwiftToolchain {
813813
private static async getSwiftTargetInfo(): Promise<SwiftTargetInfo> {
814814
try {
815815
try {
816-
const { stdout } = await execSwift(
817-
["-print-target-info", ...BuildFlags.disableSandboxFlags()],
818-
"default"
819-
);
816+
const { stdout } = await execSwift(["-print-target-info"], "default");
820817
const targetInfo = JSON.parse(stdout.trimEnd()) as SwiftTargetInfo;
821818
if (targetInfo.compilerVersion) {
822819
return targetInfo;

src/utilities/utilities.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,18 @@ export async function execFile(
109109
options.env = { ...(options.env ?? process.env), ...runtimeEnv };
110110
}
111111
}
112-
return new Promise<{ stdout: string; stderr: string }>((resolve, reject) =>
113-
cp.execFile(executable, args, options, (error, stdout, stderr) => {
114-
if (error) {
115-
reject(new ExecFileError(error, stdout, stderr));
116-
}
117-
resolve({ stdout, stderr });
118-
})
119-
);
112+
return new Promise<{ stdout: string; stderr: string }>((resolve, reject) => {
113+
try {
114+
cp.execFile(executable, args, options, (error, stdout, stderr) => {
115+
if (error) {
116+
reject(new ExecFileError(error, stdout, stderr));
117+
}
118+
resolve({ stdout, stderr });
119+
});
120+
} catch (e) {
121+
reject(e);
122+
}
123+
});
120124
}
121125

122126
export async function execFileStreamOutput(

test/integration-tests/SwiftSnippet.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ suite("SwiftSnippet Test Suite @slow", function () {
6262
// Set a breakpoint
6363
vscode.debug.addBreakpoints(breakpoints);
6464
},
65+
requiresDebugger: true,
6566
});
6667

6768
suiteTeardown(async () => {

test/integration-tests/commands/build.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ suite("Build Commands @slow", function () {
5656
async teardown() {
5757
await vscode.commands.executeCommand(Workbench.ACTION_CLOSEALLEDITORS);
5858
},
59+
requiresDebugger: true,
5960
});
6061

6162
test("Swift: Run Build", async () => {

test/integration-tests/debugger/lldb.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ suite("lldb contract test suite", () => {
3434
}
3535
workspaceContext = ctx;
3636
},
37+
requiresDebugger: true,
3738
});
3839

3940
test("getLldbProcess Contract Test, make sure the command returns", async () => {

test/integration-tests/extension.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { SwiftExecution } from "../../src/tasks/SwiftExecution";
1919
import { activateExtensionForTest } from "./utilities/testutilities";
2020
import { expect } from "chai";
2121

22-
suite("Extension Test Suite", () => {
22+
suite("Extension Test Suite", function () {
23+
this.timeout(60000);
2324
let workspaceContext: WorkspaceContext;
2425

2526
activateExtensionForTest({
@@ -42,7 +43,8 @@ suite("Extension Test Suite", () => {
4243
}).timeout(5000);*/
4344
});
4445

45-
suite("Workspace", () => {
46+
suite("Workspace", function () {
47+
this.timeout(60000);
4648
/** Verify tasks.json is being loaded */
4749
test("Tasks.json", async () => {
4850
const folder = workspaceContext.folders.find(f => f.name === "test/defaultPackage");
@@ -54,6 +56,6 @@ suite("Extension Test Suite", () => {
5456
for (const arg of ["build", "--build-tests", "--verbose"]) {
5557
assert(execution?.args.find(item => item === arg));
5658
}
57-
});
59+
}).timeout(60000);
5860
});
59-
}).timeout(15000);
61+
});

test/integration-tests/testexplorer/TestExplorerIntegration.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ suite("Test Explorer Suite", function () {
7272
await waitForTestExplorerReady(testExplorer);
7373
},
7474
requiresLSP: true,
75+
requiresDebugger: true,
7576
});
7677

7778
suite("Debugging", function () {

test/integration-tests/utilities/testutilities.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { waitForNoRunningTasks } from "../../utilities/tasks";
2323
import { closeAllEditors } from "../../utilities/commands";
2424
import { isDeepStrictEqual } from "util";
2525
import { Version } from "../../../src/utilities/version";
26+
import configuration from "../../../src/configuration";
2627

2728
function getRootWorkspaceFolder(): vscode.WorkspaceFolder {
2829
const result = vscode.workspace.workspaceFolders?.at(0);
@@ -67,7 +68,8 @@ const extensionBootstrapper = (() => {
6768
after: Mocha.HookFunction,
6869
teardown: ((this: Mocha.Context) => Promise<void>) | undefined,
6970
testAssets?: string[],
70-
requiresLSP: boolean = false
71+
requiresLSP: boolean = false,
72+
requiresDebugger: boolean = false
7173
) {
7274
let workspaceContext: WorkspaceContext | undefined;
7375
let autoTeardown: void | (() => Promise<void>);
@@ -87,6 +89,9 @@ const extensionBootstrapper = (() => {
8789
) {
8890
this.skip();
8991
}
92+
if (requiresDebugger && configuration.debugger.disable) {
93+
this.skip();
94+
}
9095
if (!setup) {
9196
return;
9297
}
@@ -204,14 +209,16 @@ const extensionBootstrapper = (() => {
204209
teardown?: (this: Mocha.Context) => Promise<void>;
205210
testAssets?: string[];
206211
requiresLSP?: boolean;
212+
requiresDebugger?: boolean;
207213
}) {
208214
testRunnerSetup(
209215
mocha.before,
210216
config?.setup,
211217
mocha.after,
212218
config?.teardown,
213219
config?.testAssets,
214-
config?.requiresLSP
220+
config?.requiresLSP,
221+
config?.requiresDebugger
215222
);
216223
},
217224

@@ -222,13 +229,17 @@ const extensionBootstrapper = (() => {
222229
) => Promise<(() => Promise<void>) | void>;
223230
teardown?: (this: Mocha.Context) => Promise<void>;
224231
testAssets?: string[];
232+
requiresLSP?: boolean;
233+
requiresDebugger?: boolean;
225234
}) {
226235
testRunnerSetup(
227236
mocha.beforeEach,
228237
config?.setup,
229238
mocha.afterEach,
230239
config?.teardown,
231-
config?.testAssets
240+
config?.testAssets,
241+
config?.requiresLSP,
242+
config?.requiresDebugger
232243
);
233244
},
234245
};

0 commit comments

Comments
 (0)