Skip to content

Commit 7567740

Browse files
committed
Finally - unit tests are running in VSCode!
1 parent 0f81874 commit 7567740

File tree

5 files changed

+120
-12
lines changed

5 files changed

+120
-12
lines changed

.vscode/extensions.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Extension recommendations for working on FieldWorks in VS Code.
3+
// Install via: Extensions view -> search by id, or use the "Install Recommended Extensions" action.
4+
"recommendations": [
5+
// C# language + unit testing inside VS Code (MSBuild-first friendly)
6+
"jetbrains.resharper-code",
7+
8+
// PowerShell scripts are part of the standard workflow (build.ps1/test.ps1/etc.)
9+
"ms-vscode.powershell",
10+
11+
// Native C++ editing/debugging helpers
12+
"ms-vscode.cpptools"
13+
],
14+
"unwantedRecommendations": [
15+
// These are great for SDK-style / dotnet-first repos, but FieldWorks is MSBuild + native-heavy.
16+
// When enabled here, they tend to drive builds/tests via `dotnet build`, which fails on .vcxproj.
17+
"ms-dotnettools.csdevkit",
18+
"ms-dotnettools.csharp"
19+
]
20+
}

.vscode/tasks.json

Lines changed: 85 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@
2727
"description": "VSTest filter (e.g., 'TestCategory!=Slow' or 'FullyQualifiedName~FwUtils')",
2828
"default": ""
2929
},
30+
{
31+
"id": "testConfiguration",
32+
"type": "pickString",
33+
"description": "Test configuration (matches test.ps1 -Configuration)",
34+
"options": ["Debug", "Release"],
35+
"default": "Debug"
36+
},
37+
{
38+
"id": "testVerbosity",
39+
"type": "pickString",
40+
"description": "Test verbosity (matches test.ps1 -Verbosity)",
41+
"options": ["quiet", "minimal", "normal", "detailed"],
42+
"default": "normal"
43+
},
3044
{
3145
"id": "testProject",
3246
"type": "promptString",
@@ -61,6 +75,19 @@
6175
}
6276
},
6377
// ==================== Build Tasks ====================
78+
{
79+
"label": "dotnet: build",
80+
"type": "shell",
81+
"command": "./build.ps1",
82+
"detail": "Override: build FieldWorks via build.ps1 (required build order & custom tasks)",
83+
"options": {
84+
"shell": {
85+
"executable": "powershell.exe",
86+
"args": ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
87+
}
88+
},
89+
"problemMatcher": "$msCompile"
90+
},
6491
{
6592
"label": "Build",
6693
"type": "shell",
@@ -94,6 +121,19 @@
94121
},
95122

96123
// ==================== Test Tasks ====================
124+
{
125+
"label": "dotnet: test",
126+
"type": "shell",
127+
"command": "./test.ps1",
128+
"detail": "Override: run FieldWorks tests via test.ps1 (handles build/test conventions)",
129+
"options": {
130+
"shell": {
131+
"executable": "powershell.exe",
132+
"args": ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
133+
}
134+
},
135+
"problemMatcher": "$msCompile"
136+
},
97137
{
98138
"label": "Test",
99139
"type": "shell",
@@ -111,10 +151,24 @@
111151
},
112152
"problemMatcher": "$msCompile"
113153
},
154+
{
155+
"label": "Test (list tests)",
156+
"type": "shell",
157+
"command": "./test.ps1 -ListTests -NoBuild -Configuration ${input:testConfiguration} -Verbosity ${input:testVerbosity}",
158+
"group": "test",
159+
"detail": "List tests via test.ps1 (requires existing built test assemblies)",
160+
"options": {
161+
"shell": {
162+
"executable": "powershell.exe",
163+
"args": ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
164+
}
165+
},
166+
"problemMatcher": "$msCompile"
167+
},
114168
{
115169
"label": "Test (with filter)",
116170
"type": "shell",
117-
"command": "./test.ps1 -TestFilter '${input:testFilter}'",
171+
"command": "./test.ps1 -TestFilter '${input:testFilter}' -Configuration ${input:testConfiguration} -Verbosity ${input:testVerbosity}",
118172
"group": "test",
119173
"detail": "Run tests with a filter expression",
120174
"options": {
@@ -128,7 +182,7 @@
128182
{
129183
"label": "Test (specific project)",
130184
"type": "shell",
131-
"command": "./test.ps1 -TestProject '${input:testProject}'",
185+
"command": "./test.ps1 -TestProject '${input:testProject}' -Configuration ${input:testConfiguration} -Verbosity ${input:testVerbosity}",
132186
"group": "test",
133187
"detail": "Run tests from a specific project",
134188
"options": {
@@ -142,7 +196,7 @@
142196
{
143197
"label": "Test (no build)",
144198
"type": "shell",
145-
"command": "./test.ps1 -NoBuild",
199+
"command": "./test.ps1 -NoBuild -Configuration ${input:testConfiguration} -Verbosity ${input:testVerbosity}",
146200
"group": "test",
147201
"detail": "Run tests without rebuilding (uses existing binaries)",
148202
"options": {
@@ -153,6 +207,34 @@
153207
},
154208
"problemMatcher": "$msCompile"
155209
},
210+
{
211+
"label": "Test (native)",
212+
"type": "shell",
213+
"command": "./test.ps1 -Native -Configuration ${input:testConfiguration}",
214+
"group": "test",
215+
"detail": "Run native tests via test.ps1 (dispatches to scripts/Agent/Invoke-CppTest.ps1)",
216+
"options": {
217+
"shell": {
218+
"executable": "powershell.exe",
219+
"args": ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
220+
}
221+
},
222+
"problemMatcher": "$msCompile"
223+
},
224+
{
225+
"label": "Test (native, no build)",
226+
"type": "shell",
227+
"command": "./test.ps1 -Native -NoBuild -Configuration ${input:testConfiguration}",
228+
"group": "test",
229+
"detail": "Run native tests via test.ps1 without rebuilding",
230+
"options": {
231+
"shell": {
232+
"executable": "powershell.exe",
233+
"args": ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
234+
}
235+
},
236+
"problemMatcher": "$msCompile"
237+
},
156238

157239
// ==================== CI Parity Checks ====================
158240
{

Build/Src/FwBuildTasks/FwBuildTasks.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55
<Description>Additional msbuild tasks for FieldWorks</Description>
66
<Product>FwBuildTasks</Product>
77
<TargetFramework>net48</TargetFramework>
8-
<!-- Use container-local output path when in Docker to avoid bind-mount conflicts with host Serena/OmniSharp -->
9-
<OutputPath Condition="'$(DOTNET_RUNNING_IN_CONTAINER)' != 'true'">$(FwRoot)BuildTools\FwBuildTasks\$(Configuration)\</OutputPath>
10-
<OutputPath Condition="'$(DOTNET_RUNNING_IN_CONTAINER)' == 'true'">C:\Temp\BuildTools\FwBuildTasks\$(Configuration)\</OutputPath>
8+
<!--
9+
Output policy:
10+
- By default, build outputs to the project bin folder.
11+
This avoids file-lock conflicts when the build tasks assembly is already loaded by MSBuild nodes
12+
(common when building the full solution in an IDE).
13+
- build.ps1 bootstrapping passes FwBuildTasksOutputPath to publish the tasks into BuildTools.
14+
- In containers, build.ps1 may pass a container-local path.
15+
-->
16+
<OutputPath Condition="'$(FwBuildTasksOutputPath)' != ''">$(FwBuildTasksOutputPath)</OutputPath>
1117
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1218
<DefaultItemExcludes>$(DefaultItemExcludes);obj\**</DefaultItemExcludes>
1319
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

Build/Windows.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<UsingTask
2525
TaskName="CheckAdminPrivilege"
2626
AssemblyFile="$(FwBuildTasksAssembly)"
27-
Condition="'$(OS)'=='Windows_NT'"
27+
Condition="'$(OS)'=='Windows_NT' AND '$(SkipFwBuildTasksUsingTask)' != 'true' AND Exists('$(FwBuildTasksAssembly)')"
2828
/>
29-
<UsingTask TaskName="RegFree" AssemblyFile="$(FwBuildTasksAssembly)" />
29+
<UsingTask TaskName="RegFree" AssemblyFile="$(FwBuildTasksAssembly)" Condition="'$(SkipFwBuildTasksUsingTask)' != 'true' AND Exists('$(FwBuildTasksAssembly)')" />
3030
<UsingTask
3131
TaskName="FindXsltcPath"
3232
TaskFactory="CodeTaskFactory"

build.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,8 @@ try {
185185
$finalMsBuildArgs += "/p:SkipNative=true"
186186
}
187187
$finalMsBuildArgs += "/p:CL_MPCount=$mpCount"
188-
f ($env:FW_TRACE_LOG) {
189-
$finalMsBuildArgs += "/p:FW_TRACE_LOG=`"$($env:FW_TRACE_LOG)`""
190-
}
188+
if ($env:FW_TRACE_LOG) {
189+
$finalMsBuildArgs += "/p:FW_TRACE_LOG=`"$($env:FW_TRACE_LOG)`""
191190
}
192191

193192
if ($BuildTests -or $RunTests) {
@@ -216,8 +215,9 @@ f ($env:FW_TRACE_LOG) {
216215
}
217216

218217
# Bootstrap: Build FwBuildTasks first (required by SetupInclude.targets)
218+
$fwBuildTasksOutputDir = Join-Path $PSScriptRoot "BuildTools/FwBuildTasks/$Configuration/"
219219
Invoke-MSBuild `
220-
-Arguments @('Build/Src/FwBuildTasks/FwBuildTasks.csproj', '/t:Restore;Build', "/p:Configuration=$Configuration", "/p:Platform=$Platform", "/p:SkipFwBuildTasksAssemblyCheck=true", "/p:SkipFwBuildTasksUsingTask=true", "/p:SkipGenerateFwTargets=true", "/p:SkipSetupTargets=true", "/v:quiet", "/nologo") `
220+
-Arguments @('Build/Src/FwBuildTasks/FwBuildTasks.csproj', '/t:Restore;Build', "/p:Configuration=$Configuration", "/p:Platform=$Platform", "/p:FwBuildTasksOutputPath=$fwBuildTasksOutputDir", "/p:SkipFwBuildTasksAssemblyCheck=true", "/p:SkipFwBuildTasksUsingTask=true", "/p:SkipGenerateFwTargets=true", "/p:SkipSetupTargets=true", "/v:quiet", "/nologo") `
221221
-Description 'FwBuildTasks (Bootstrap)'
222222

223223
if (-not (Test-Path $fwTasksSourcePath)) {

0 commit comments

Comments
 (0)