Skip to content

Commit

Permalink
Merge pull request #7560 from dibarbet/devkit_integration_tests
Browse files Browse the repository at this point in the history
Update integration tests to also run against C# Dev Kit
  • Loading branch information
dibarbet authored Sep 17, 2024
2 parents 1644291 + 1426bf4 commit 0eed89b
Show file tree
Hide file tree
Showing 73 changed files with 1,064 additions and 1,385 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/no-require-imports": "off",
// Allow unused vars if prefixed by _
"@typescript-eslint/no-unused-vars": [
"warn",
Expand Down
43 changes: 34 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"args": [
// Launch VSCode using a specific profile to ensure that user settings are not used.
// This profile must be imported into vscode before running this launch configuration.
// The profile can be found under /test/csharp-standalone-profile.
// The profile can be found under /test/csharp-test-profile.
"--profile",
"csharp-standalone-profile",
"${workspaceRoot}/test/lsptoolshost/integrationTests/testAssets/slnWithCsproj/.vscode/lsp_tools_host_slnWithCsproj.code-workspace",
"csharp-test-profile",
"${workspaceRoot}/test/lsptoolshost/integrationTests/testAssets/slnWithCsproj/.vscode/slnWithCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/lsptoolshost/integrationTests"
],
Expand All @@ -36,6 +36,31 @@
"preLaunchTask": "buildDev",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "[DevKit] Launch Current File slnWithCsproj Integration Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
// Launch VSCode using a specific profile to ensure that user settings are not used.
// This profile must be imported into vscode before running this launch configuration.
// The profile can be found under /test/csharp-test-profile.
"--profile",
"csharp-test-profile",
"${workspaceRoot}/test/lsptoolshost/integrationTests/testAssets/slnWithCsproj/.vscode/devkit_slnWithCsproj.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/lsptoolshost/integrationTests"
],
"env": {
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"TEST_FILE_FILTER": "${file}",
},
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/dist/*.js", "${workspaceRoot}/out/test/**/*.js"],
"resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"],
"preLaunchTask": "buildDev",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Launch Current File BasicRazorApp2_1 Integration Tests",
"type": "extensionHost",
Expand All @@ -44,9 +69,9 @@
"args": [
// Launch VSCode using a specific profile to ensure that user settings are not used.
// This profile must be imported into vscode before running this launch configuration.
// The profile can be found under /test/csharp-standalone-profile.
// The profile can be found under /test/csharp-test-profile.
"--profile",
"csharp-standalone-profile",
"csharp-test-profile",
"${workspaceRoot}/test/razor/razorIntegrationTests/testAssets/BasicRazorApp2_1/.vscode/lsp_tools_host_BasicRazorApp2_1.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/razor/razorIntegrationTests"
Expand All @@ -69,9 +94,9 @@
"args": [
// Launch VSCode using a specific profile to ensure that user settings are not used.
// This profile must be imported into vscode before running this launch configuration.
// The profile can be found under /test/csharp-standalone-profile.
// The profile can be found under /test/csharp-test-profile.
"--profile",
"csharp-standalone-profile",
"csharp-test-profile",
"${workspaceRoot}/test/omnisharp/omnisharpIntegrationTests/testAssets/${input:omnisharpAssetName}/.vscode/omnisharp_${input:omnisharpAssetName}.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests"
Expand All @@ -94,9 +119,9 @@
"args": [
// Launch VSCode using a specific profile to ensure that user settings are not used.
// This profile must be imported into vscode before running this launch configuration.
// The profile can be found under /test/csharp-standalone-profile.
// The profile can be found under /test/csharp-test-profile.
"--profile",
"csharp-standalone-profile",
"csharp-test-profile",
"${workspaceRoot}/test/omnisharp/omnisharpIntegrationTests/testAssets/${input:omnisharpAssetName}/.vscode/omnisharp_lsp_${input:omnisharpAssetName}.code-workspace",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test/omnisharp/omnisharpIntegrationTests"
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ To run all tests, execute `npm run test`.
To debug unit tests locally, press <kbd>F5</kbd> in VS Code with the "Launch Tests" debug configuration selected.

To debug integration tests
1. Import the `csharp-standalone-profile.code-profile` in VSCode to setup a clean profile in which to run integration tests. This must be imported at least once to use the launch configurations.
1. Import the `csharp-test-profile.code-profile` in VSCode to setup a clean profile in which to run integration tests. This must be imported at least once to use the launch configurations (ensure the extensions are updated in the profile).
2. Open any integration test file and <kbd>F5</kbd> launch with the correct launch configuration selected.
- For integration tests inside `test/lsptoolshost`, use `Launch Current File slnWithCsproj Integration Tests`
- For integration tests inside `test/lsptoolshost`, use either `Launch Current File slnWithCsproj Integration Tests` or `[DevKit] Launch Current File slnWithCsproj Integration Tests` (to run tests using C# + C# Dev Kit)
- For integration tests inside `test/razor`, use `Launch Current File BasicRazorApp2_1 Integration Tests`
- For integration tests inside `test/omnisharp`, use one of the `Omnisharp:` current file profiles

Expand Down
77 changes: 37 additions & 40 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,58 +24,55 @@ stages:
isOfficial: false
signType: test

- stage: Test_Linux_Stage
displayName: Test Linux
- stage:
displayName: Test Linux (.NET 6)
dependsOn: []
jobs:
- job: Test_Linux_Job
displayName: Test Linux
strategy:
matrix:
DotNet6:
containerName: mcr.microsoft.com/dotnet/sdk:6.0
DotNet7:
containerName: mcr.microsoft.com/dotnet/sdk:7.0
DotNet8:
containerName: mcr.microsoft.com/dotnet/sdk:8.0
pool:
name: NetCore-Public
demands: ImageOverride -equals 1es-ubuntu-2004-open
container: $[ variables['containerName'] ]
steps:
- template: azure-pipelines/test.yml
parameters:
# Prefer the dotnet from the container.
installDotNet: false
installAdditionalLinuxDependencies: true
- template: azure-pipelines/test-matrix.yml
parameters:
# Prefer the dotnet from the container.
installDotNet: false
installAdditionalLinuxDependencies: true
pool:
name: NetCore-Public
demands: ImageOverride -equals 1es-ubuntu-2004-open
containerName: mcr.microsoft.com/dotnet/sdk:6.0

- stage:
displayName: Test Linux (.NET 8)
dependsOn: []
jobs:
- template: azure-pipelines/test-matrix.yml
parameters:
# Prefer the dotnet from the container.
installDotNet: false
installAdditionalLinuxDependencies: true
pool:
name: NetCore-Public
demands: ImageOverride -equals 1es-ubuntu-2004-open
containerName: mcr.microsoft.com/dotnet/sdk:8.0

- stage: Test_Windows_Stage
displayName: Test Windows
dependsOn: []
jobs:
- job: Test_Windows_Job
displayName: Test Windows
pool:
name: NetCore-Public
demands: ImageOverride -equals 1es-windows-2022-open
steps:
- template: azure-pipelines/test.yml
parameters:
installDotNet: true
- template: azure-pipelines/test-matrix.yml
parameters:
installDotNet: true
pool:
name: NetCore-Public
demands: ImageOverride -equals 1es-windows-2022-open

- stage: Test_MacOS_Stage
displayName: Test MacOS
dependsOn: []
jobs:
- job: Test_MacOS_Job
displayName: Test MacOS
pool:
name: Azure Pipelines
vmImage: macOS-13
steps:
- template: azure-pipelines/test.yml
parameters:
installDotNet: true
- template: azure-pipelines/test-matrix.yml
parameters:
installDotNet: true
pool:
name: Azure Pipelines
vmImage: macOS-13

- stage: Test_OmniSharp
displayName: Test OmniSharp
Expand Down
30 changes: 30 additions & 0 deletions azure-pipelines/test-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
parameters:
- name: pool
type: object
- name: containerName
type: string
default: ''
- name: installDotNet
type: boolean
- name: installAdditionalLinuxDependencies
type: boolean
default: false

jobs:
- job:
strategy:
matrix:
CSharpTests:
npmCommand: 'test:withoutDevKit'
DevKitTests:
npmCommand: test:integration:devkit
pool: ${{ parameters.pool }}
${{ if parameters.containerName }}:
container: ${{ parameters.containerName }}
steps:
- template: /azure-pipelines/test.yml@self
parameters:
# Prefer the dotnet from the container.
installDotNet: false
installAdditionalLinuxDependencies: true
npmCommand: $(npmCommand)
12 changes: 7 additions & 5 deletions azure-pipelines/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ parameters:
- name: installAdditionalLinuxDependencies
type: boolean
default: false
- name: npmCommand
type: string

steps:
- checkout: self
Expand All @@ -23,8 +25,8 @@ steps:
parameters:
installAdditionalLinuxDependencies: ${{ parameters.installAdditionalLinuxDependencies }}

- script: npm run test
displayName: 🧪 Run unit and integration tests
- script: npm run ${{ parameters.npmCommand }}
displayName: 🧪 Run $(Agent.JobName)
env:
DISPLAY: :99.0

Expand All @@ -37,11 +39,11 @@ steps:
searchFolder: '$(Build.SourcesDirectory)/out'
publishRunAttachments: true
mergeTestResults: true
testRunTitle: $(Agent.JobName) (Attempt $(System.JobAttempt))
testRunTitle: $(System.StageDisplayName) $(Agent.JobName) (Attempt $(System.JobAttempt))

- task: PublishPipelineArtifact@1
condition: failed()
displayName: 'Upload integration test logs'
inputs:
targetPath: '$(Build.SourcesDirectory)/.vscode-test/user-data/logs'
artifactName: 'VSCode Test Logs ($(Agent.JobName)-$(System.JobAttempt))'
targetPath: '$(Build.SourcesDirectory)/out/logs'
artifactName: 'Test Logs ($(System.StageDisplayName)-$(Agent.JobName)-$(System.JobAttempt))'
3 changes: 2 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const config: Config = {
// Azure DevOps does not display test suites (it ignores them entirely).
// So we have to put all the info in the test case name so the UI shows anything relatively useful.
// See https://github.com/microsoft/azure-pipelines-tasks/issues/7659
titleTemplate: '{filename} / {suitename} / {title}',
classNameTemplate: '{suitename}',
titleTemplate: `${process.env.JEST_SUITE_NAME} {suitename} / {title}`,
},
],
],
Expand Down
Loading

0 comments on commit 0eed89b

Please sign in to comment.