Original file line numberDiff line numberDiff line change
Expand Up@@ -89,6 +89,42 @@ module.exports = defineConfig({
reuseMachineInstall: !isCIBuild,
installExtensions,
},
{
label: "codeWorkspaceTests",
files: [
"dist/test/common.js",
"dist/test/integration-tests/extension.test.js",
"dist/test/integration-tests/WorkspaceContext.test.js",
"dist/test/integration-tests/tasks/**/*.test.js",
"dist/test/integration-tests/commands/build.test.js",
"dist/test/integration-tests/testexplorer/TestExplorerIntegration.test.js",
"dist/test/integration-tests/commands/dependency.test.js",
],
version: process.env["VSCODE_VERSION"] ?? "stable",
workspaceFolder: "./assets/test.code-workspace",
launchArgs,
extensionDevelopmentPath: vsixPath
? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${version}`]
: undefined,
mocha: {
ui: "tdd",
color: true,
timeout,
forbidOnly: isCIBuild,
grep: isFastTestRun ? "@slow" : undefined,
invert: isFastTestRun,
slow: 10000,
retries: 1,
reporter: path.join(__dirname, ".mocha-reporter.js"),
reporterOptions: {
jsonReporterOptions: {
output: path.join(__dirname, "test-results", "code-workspace-tests.json"),
},
},
},
reuseMachineInstall: !isCIBuild,
installExtensions,
},
{
label: "unitTests",
files: ["dist/test/common.js", "dist/test/unit-tests/**/*.test.js"],
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,19 @@
},
"preLaunchTask": "compile-tests"
},
{
"name": "Code Workspace Tests",
"type": "extensionHost",
"request": "launch",
"testConfiguration": "${workspaceFolder}/.vscode-test.js",
"testConfigurationLabel": "codeWorkspaceTests",
"args": ["--profile=testing-debug"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"env": {
"VSCODE_DEBUG": "1"
},
"preLaunchTask": "compile-tests"
},
{
"name": "Unit Tests",
"type": "extensionHost",
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
{
"folders": [
{
"name": "diagnostics",
"path": "./test/diagnostics"
},
{
"name": "dependencies",
"path": "./test/dependencies"
},
{
"name": "command-plugin",
"path": "./test/command-plugin"
},
{
"name": "defaultPackage",
"path": "./test/defaultPackage"
}
],
"settings": {
"swift.disableAutoResolve": true,
"swift.autoGenerateLaunchConfigurations": false,
"swift.debugger.debugAdapter": "lldb-dap",
"swift.debugger.setupCodeLLDB": "alwaysUpdateGlobal",
"swift.additionalTestArguments": [
"-Xswiftc",
"-DTEST_ARGUMENT_SET_VIA_TEST_BUILD_ARGUMENTS_SETTING"
],
"lldb.verboseLogging": true,
"lldb.launch.terminal": "external",
"lldb-dap.detachOnError": true,
"swift.sourcekit-lsp.backgroundIndexing": "off"
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"type": "swift",
"args": [
"build",
"--build-tests",
"--verbose",
"-Xswiftc",
"-DBAR"
],
"cwd": "${workspaceFolder:defaultPackage}",
"group": {
"kind": "build",
"isDefault": true
},
"label": "swift: Build All (defaultPackage) (workspace)",
"detail": "swift build --build-tests --verbose -Xswiftc -DBAR"
},
{
"type": "swift",
"args": [
"build",
"--show-bin-path"
],
"cwd": "${workspaceFolder:defaultPackage}",
"group": "build",
"label": "swift: Build All from code workspace",
"detail": "swift build --show-bin-path"
},
{
"type": "swift-plugin",
"command": "command_plugin",
"args": [
"--foo"
],
"cwd": "${workspaceFolder:command-plugin}",
"disableSandbox": true,
"label": "swift: command-plugin from code workspace",
"detail": "swift package command_plugin --foo"
},
{
"type": "swift",
"args": [
"build",
"--product",
"PackageExe",
"-Xswiftc",
"-diagnostic-style=llvm",
"-Xswiftc",
"-DBAR"
],
"cwd": "${workspaceFolder:defaultPackage}",
"group": "build",
"label": "swift: Build Debug PackageExe (defaultPackage) (workspace)",
"detail": "swift build --product PackageExe -Xswiftc -diagnostic-style=llvm -Xswiftc -DBAR"
},
{
"type": "swift",
"args": [
"build",
"-c",
"release",
"--product",
"PackageExe",
"-Xswiftc",
"-diagnostic-style=llvm",
"-Xswiftc",
"-DBAR"
],
"cwd": "${workspaceFolder:defaultPackage}",
"group": "build",
"label": "swift: Build Release PackageExe (defaultPackage) (workspace)",
"detail": "swift build -c release --product PackageExe -Xswiftc -diagnostic-style=llvm -Xswiftc -DBAR"
}
]
},
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "swift",
"request": "launch",
"name": "Debug PackageExe (defaultPackage) (workspace)",
"program": "${workspaceFolder:defaultPackage}/.build/debug/PackageExe",
"args": [],
"cwd": "${workspaceFolder:defaultPackage}",
"preLaunchTask": "swift: Build Debug PackageExe (defaultPackage) (workspace)",
"disableASLR": false,
"initCommands": [
"settings set target.disable-aslr false"
]
},
{
"type": "swift",
"request": "launch",
"name": "Release PackageExe (defaultPackage) (workspace)",
"program": "${workspaceFolder:defaultPackage}/.build/release/PackageExe",
"args": [],
"cwd": "${workspaceFolder:defaultPackage}",
"preLaunchTask": "swift: Build Release PackageExe (defaultPackage) (workspace)",
"disableASLR": false,
"initCommands": [
"settings set target.disable-aslr false"
]
}
],
"compounds": []
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,15 +6,17 @@
"args": [
"build",
"--build-tests",
"--verbose"
"--verbose",
"-Xswiftc",
"-DFOO"
],
"cwd": "defaultPackage",
"problemMatcher": [
"$swiftc"
],
"group": "build",
"label": "swift: Build All (defaultPackage)",
"detail": "swift build --build-tests --verbose"
"detail": "swift build --build-tests --verbose -Xswiftc -DFOO"
},
{
"type": "swift",
Expand All@@ -33,7 +35,9 @@
{
"type": "swift-plugin",
"command": "command_plugin",
"args": ["--foo"],
"args": [
"--foo"
],
"cwd": "command-plugin",
"disableSandbox": true,
"problemMatcher": [
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
{
"configurations": [
{
"type": "swift",
"request": "launch",
"name": "Attach to Swift Executable",
"program": "${workspaceFolder}/.build/aarch64-unknown-linux-gnu/debug/PackageExe",
// "attachCommands": [
// // "gdb-remote 1234",
// // "process launch"
// "platform select remote-linux",
// "platform connect connect://127.0.0.1:1234"
// ],
// "initCommands": [
// "target create .build/aarch64-unknown-linux-gnu/debug/PackageExe",
// "b main.swift:7",
// ]
"initCommands": [
"platform select remote-linux",
// "platform connect connect://127.0.0.1:1234",
"gdb-remote 1234",
"settings set target.inherit-env false"
]
},
{
"type": "swift",
"request": "launch",
"name": "Debug package1",
"program": "${workspaceFolder:defaultPackage}/.build/debug/package1",
"args": [],
"cwd": "${workspaceFolder:defaultPackage}",
"preLaunchTask": "swift: Build Debug package1"
},
{
"type": "swift",
"request": "launch",
"name": "Release package1",
"program": "${workspaceFolder:defaultPackage}/.build/release/package1",
"args": [],
"cwd": "${workspaceFolder:defaultPackage}",
"preLaunchTask": "swift: Build Release package1"
},
{
"type": "swift",
"request": "launch",
"args": [],
"cwd": "${workspaceFolder:defaultPackage}",
"name": "Debug PackageExe",
"program": "${workspaceFolder:defaultPackage}/.build/debug/PackageExe",
"preLaunchTask": "swift: Build Debug PackageExe"
},
{
"type": "swift",
"request": "launch",
"args": [],
"cwd": "${workspaceFolder:defaultPackage}",
"name": "Release PackageExe",
"program": "${workspaceFolder:defaultPackage}/.build/release/PackageExe",
"preLaunchTask": "swift: Build Release PackageExe"
}
]
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
function Update-SwiftBuildAndPackageArguments {
param (
[string]$jsonFilePath = "./assets/test/.vscode/settings.json",
[string]$codeWorkspaceFilePath = "./assets/test.code-workspace",
[string]$windowsSdkVersion = "10.0.22000.0",
[string]$vcToolsVersion = "14.43.34808"
)
Expand All@@ -28,9 +29,17 @@ function Update-SwiftBuildAndPackageArguments {
exit 1
}

try {
$codeWorkspaceContent = Get-Content -Raw -Path $codeWorkspaceFilePath | ConvertFrom-Json
} catch {
Write-Host "Invalid JSON content in $codeWorkspaceFilePath"
exit 1
}

if ($jsonContent.PSObject.Properties['swift.buildArguments']) {
$jsonContent.PSObject.Properties.Remove('swift.buildArguments')
}


$jsonContent | Add-Member -MemberType NoteProperty -Name "swift.buildArguments" -Value @(
"-Xbuild-tools-swiftc", "-windows-sdk-root", "-Xbuild-tools-swiftc", $windowsSdkRoot,
Expand All@@ -54,10 +63,20 @@ function Update-SwiftBuildAndPackageArguments {
"-Xswiftc", "-visualc-tools-version", "-Xswiftc", $vcToolsVersion
)


$codeWorkspaceContent.PSObject.Properties.Remove('settings')
$codeWorkspaceContent | Add-Member -MemberType NoteProperty -Name "settings" -Value $jsonContent

$jsonContent | ConvertTo-Json -Depth 32 | Set-Content -Path $jsonFilePath


$codeWorkspaceContent | ConvertTo-Json -Depth 32 | Set-Content -Path $codeWorkspaceFilePath

Write-Host "Contents of ${jsonFilePath}:"
Get-Content -Path $jsonFilePath

Write-Host "Contents of ${codeWorkspaceFilePath}:"
Get-Content -Path $codeWorkspaceFilePath
}

$swiftVersionOutput = & swift --version
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,6 +51,7 @@ import { reduceTestItemChildren } from "./TestUtils";
import { CompositeCancellationToken } from "../utilities/cancellation";
// eslint-disable-next-line @typescript-eslint/no-require-imports
import stripAnsi = require("strip-ansi");
import { packageName, resolveScope } from "../utilities/tasks";

export enum TestLibrary {
xctest = "XCTest",
Expand DownExpand Up@@ -773,8 +774,8 @@ export class TestRunner {
`Building and Running Tests${kindLabel}`,
{
cwd: this.folderContext.folder,
scope: this.folderContext.workspaceFolder,
prefix: this.folderContext.name,
scope: resolveScope(this.folderContext.workspaceFolder),
packageName: packageName(this.folderContext),
presentationOptions: { reveal: vscode.TaskRevealKind.Never },
},
this.folderContext.toolchain,
Expand Down
Loading