Skip to content

Commit

Permalink
(#1 in order) upgrade the tests [ready] (#1881)
Browse files Browse the repository at this point in the history
  • Loading branch information
elahehrashedi authored Jun 14, 2021
1 parent 379856c commit 75c91a1
Show file tree
Hide file tree
Showing 67 changed files with 930 additions and 1,191 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci-develop-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ jobs:
sudo apt update
sudo apt install powershell gdb xvfb
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: '14'
# Set this option if you want the action to check for the latest available version that satisfies the version spec
check-latest: true

- name: Build the extension and run tests
uses: GabrielBB/xvfb-action@v1.4
with:
# Command to execute using xvfb
run: pwsh -NonInteractive -NoProfile -NoLogo scripts/ci.ps1
run: pwsh -NonInteractive -NoProfile -NoLogo scripts/ci.ps1
3 changes: 2 additions & 1 deletion .github/workflows/ci-develop-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
- uses: actions/checkout@v2

- name: Setup Node.js environment
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v2
with:
node-version: '14'
# Set this option if you want the action to check for the latest available version that satisfies the version spec
check-latest: true

Expand Down
57 changes: 11 additions & 46 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"smartStep": false
},
{
"name": "Launch Tests",
"name": "Launch Unit Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceFolder}/test/unit-tests/test-project-without-cmakelists",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/unit-tests"
"--extensionTestsPath=${workspaceFolder}/out/test/unit-tests/index"
],
"stopOnEntry": false,
"sourceMaps": true,
Expand All @@ -44,42 +44,7 @@
"CMT_QUIET_CONSOLE": "1",
"HasVs": "true"
},
"preLaunchTask": "build-tests-with-tsc-watch"
},
{
"name": "Launch Extension Tests (without-cmakelist-file)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceFolder}/test/extension-tests/without-cmakelist-file/project-folder",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/without-cmakelist-file"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/*",
"${workspaceFolder}/out/src/*",
"${workspaceFolder}/out/test/*",
"${workspaceFolder}/out/test/extension-tests/without-cmakelist-file/*",
"${workspaceFolder}/out/test/extension-tests/without-cmakelist-file/test/*"
],
"preLaunchTask": "build-tests-with-tsc-watch",
"windows": {
"env": {
"CMT_TESTING": "1",
"CMT_QUIET_CONSOLE": "1",
"HasVs": "true"
}
},
"linux": {
"env": {
"CMT_TESTING": "1",
"CMT_QUIET_CONSOLE": "1",
"HasVs": "false"
}
}
"preLaunchTask": "Pretest"
},
{
"name": "Launch Extension Tests (successful-build)",
Expand All @@ -89,7 +54,7 @@
"args": [
"${workspaceFolder}/test/extension-tests/successful-build/project-folder",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/successful-build"
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/successful-build/index"
],
"stopOnEntry": false,
"sourceMaps": true,
Expand All @@ -100,7 +65,7 @@
"${workspaceFolder}/out/test/extension-tests/successful-build/*",
"${workspaceFolder}/out/test/extension-tests/successful-build/test/*"
],
"preLaunchTask": "build-tests-with-tsc-watch",
"preLaunchTask": "Pretest",
"windows": {
"env": {
"CMT_TESTING": "1",
Expand Down Expand Up @@ -131,7 +96,7 @@
"args": [
"${workspaceFolder}/test/extension-tests/single-root-UI/project-folder",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/single-root-UI"
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/single-root-UI/index"
],
"stopOnEntry": false,
"sourceMaps": true,
Expand All @@ -142,7 +107,7 @@
"${workspaceFolder}/out/test/extension-tests/single-root-UI/*",
"${workspaceFolder}/out/test/extension-tests/single-root-UI/test/*"
],
"preLaunchTask": "build-tests-with-tsc-watch",
"preLaunchTask": "Pretest",
"windows": {
"env": {
"CMT_TESTING": "1",
Expand Down Expand Up @@ -173,7 +138,7 @@
"args": [
"${workspaceFolder}/test/extension-tests/multi-root-UI/project-workspace.code-workspace",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/multi-root-UI"
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/multi-root-UI/index"
],
"stopOnEntry": false,
"sourceMaps": true,
Expand All @@ -184,7 +149,7 @@
"${workspaceFolder}/out/test/extension-tests/multi-root-UI/*",
"${workspaceFolder}/out/test/extension-tests/multi-root-UI/test/*"
],
"preLaunchTask": "build-tests-with-tsc-watch",
"preLaunchTask": "Pretest",
"windows": {
"env": {
"CMT_TESTING": "1",
Expand Down Expand Up @@ -232,7 +197,7 @@
"args": [
"${workspaceFolder}/test/smoke/_project-dir",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/smoke",
"--extensionTestsPath=${workspaceFolder}/out/test/smoke/index",
"--disable-extensions"
],
"stopOnEntry": false,
Expand All @@ -241,7 +206,7 @@
"${workspaceFolder}/out/*",
"${workspaceFolder}/out/test/**"
],
"preLaunchTask": "build-tests-with-tsc-watch",
"preLaunchTask": "Pretest",
"env": {
"CMT_TESTING": "1",
"CMT_QUIET_CONSOLE": "1",
Expand Down
36 changes: 23 additions & 13 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,29 @@
"isBackground": true
},
{
"label": "build-tests-with-tsc-watch",
"type": "npm",
"script": "pretest",
"problemMatcher": [
"$tsc-watch"
"label": "Pretest",
"group": "build",
"isBackground": false,
"type": "shell",
"command": "yarn",
"args": [
"run",
"pretest"
],
"isBackground": true,
"presentation": {
"echo": false,
"reveal": "silent",
"showReuseMessage": false,
"clear": true
}
}
"dependsOn": [
"Compile"
]
},
{
"label": "Compile",
"group": "build",
"isBackground": false,
"type": "shell",
"command": "yarn",
"args": [
"run",
"compile"
]
},
]
}
25 changes: 17 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"native"
],
"engines": {
"vscode": "^1.30.0"
"vscode": "^1.53.0"
},
"categories": [
"Other"
Expand Down Expand Up @@ -1897,14 +1897,20 @@
},
"scripts": {
"vscode:prepublish": "yarn run compile-production",
"compile": "yarn install && webpack --mode development --watch --progress",
"compile": "yarn install && webpack --mode development",
"compile-watch": "yarn install && webpack --mode development --watch --progress",
"compile-production": "yarn install && yarn run translations-generate && webpack --env BUILD_VSCODE_NLS=true --mode production",
"translations-export": "gulp translations-export",
"translations-generate": "gulp translations-generate",
"translations-import": "gulp translations-import",
"pretest": "tsc -p test.tsconfig.json",
"postinstall": "node ./node_modules/vscode/bin/install",
"pr-check": "gulp pr-check",
"lint": "gulp lint",
"smokeTests": "yarn run pretest && node ./out/test/smoke/runTest.js",
"unitTests": "yarn run pretest && node ./out/test/unit-tests/runTest.js",
"extensionTestsSuccessfulBuild": "yarn run pretest && node ./out/test/extension-tests/successful-build/runTest.js",
"extensionTestsSingleRoot": "yarn run pretest && node ./out/test/extension-tests/single-root-UI/runTest.js",
"extensionTestsMultioot": "yarn run pretest && node ./out/test/extension-tests/multi-root-UI/runTest.js",
"docs": "node ./node_modules/typedoc/bin/typedoc --excludeExternals --out build/docs/dev --readme none src/ types/"
},
"devDependencies": {
Expand All @@ -1915,11 +1921,12 @@
"@types/chai-string": "^1.4.2",
"@types/js-yaml": "^4.0.0",
"@types/json5": "~0.0.30",
"@types/mocha": "~8.2.0",
"@types/mocha": "^8.2.2",
"@types/node": "~14.14.28",
"@types/rimraf": "^3.0.0",
"@types/sinon": "~9.0.10",
"@types/tmp": "^0.2.0",
"@types/vscode": "1.53.0",
"@types/which": "~2.0.0",
"@types/xml2js": "^0.4.8",
"@typescript-eslint/eslint-plugin": "^4.22.1",
Expand All @@ -1934,25 +1941,27 @@
"eslint-plugin-jsdoc": "^33.1.0",
"event-stream": "^4.0.1",
"fs-extra": "^9.1.0",
"glob": "^7.1.6",
"gulp": "^4.0.2",
"gulp-eslint": "^6.0.0",
"gulp-filter": "^6.0.0",
"gulp-mocha": "^8.0.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-typescript": "^5.0.1",
"jsonc-parser": "^3.0.0",
"mocha": "^8.3.0",
"mocha": "^8.3.2",
"module-alias": "^2.2.2",
"node-loader": "^1.0.2",
"parse-git-config": "^3.0.0",
"sinon": "~9.2.4",
"ts-loader": "^8.0.17",
"ts-node": "^9.1.1",
"tslint": "^5.20.1",
"typedoc": "^0.20.25",
"typedoc": "^0.20.36",
"typescript": "^4.1.5",
"vscode": "^1.1.36",
"vscode-nls-dev": "^3.3.2",
"webpack": "^5.22.0",
"vscode-test": "^1.5.2",
"webpack": "^5.38.1",
"webpack-cli": "^4.5.0"
},
"dependencies": {
Expand Down
87 changes: 11 additions & 76 deletions scripts/ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,6 @@ Import-Module (Join-Path $PSScriptRoot "cmt.psm1")

$DOC_BUILD_DIR = Join-Path $REPO_DIR "build/docs"

if ($Test) {
foreach ($testname in $Test) {
Invoke-SmokeTest $testname
}
return
}

if ($OnlySmoke) {
return Invoke-SmokeTests
}

if ($OnlyUnit) {
return Invoke-VSCodeTest "CMake Tools: Unit tests" `
-TestsPath "$REPO_DIR/out/test/unit-tests" `
-Workspace "$REPO_DIR/test/unit-tests/test-project-without-cmakelists"
}

# Sanity check for yarn
$yarn = Find-Program yarn
if (! $yarn) {
Expand All @@ -72,26 +55,6 @@ if (! $yarn) {
}
}

function Invoke-DocsBuild {
Build-DevDocs
Build-UserDocs `
-RepoDir $REPO_DIR `
-Version $CMakeToolsVersion`
-Out $DOC_BUILD_DIR

if ($DocDestination) {
Write-Host "Copying documentation tree to $DocDestination"
if (Test-Path $DocDestination) {
Remove-Item $DocDestination -Recurse -Force
}
Copy-Item $DOC_BUILD_DIR -Destination $DocDestination -Recurse
}
}

if ($Docs) {
return Invoke-DocsBuild
}

$out_dir = Join-Path $REPO_DIR out
if (Test-Path $out_dir) {
Write-Verbose "Removing out/ directory: $out_dir"
Expand All @@ -104,14 +67,10 @@ Invoke-ChronicCommand "yarn install" $yarn install
# Now do the real compile
Invoke-ChronicCommand "Compiling TypeScript" $yarn run compile-production

# Now compile test code
Invoke-ChronicCommand "Compiling Tests" $yarn run pretest

# Run EsLint to check for silly mistakes
Invoke-ChronicCommand "Running TSLint" $yarn run lint

# Get the CMake binary that we will use to run our tests
$cmake_binary = Install-TestCMake -Version "3.16.2"
# The cmake server mode has been removed since CMake 3.20. Clients should use the cmake-file-api(7) instead.
$cmake_binary = Install-TestCMake -Version "3.18.2"
$Env:CMAKE_EXECUTABLE = $cmake_binary

# Add cmake to search path environment variable
Expand All @@ -138,38 +97,14 @@ $ninja_binary = Install-TestNinjaMakeSystem -Version "1.8.2"
# Add ninja to search path environment variable
$Env:PATH = (get-item $ninja_binary).Directory.FullName + [System.IO.Path]::PathSeparator + $Env:PATH

if (! $NoTest) {
# Prepare to run our tests
Invoke-TestPreparation -CMakePath $cmake_binary

# Running mocha backend tests
Invoke-MochaTest "CMake Tools: Backend tests"

Invoke-VSCodeTest "CMake Tools: Unit tests" `
-TestsPath "$REPO_DIR/out/test/unit-tests" `
-Workspace "$REPO_DIR/test/unit-tests/test-project-without-cmakelists"

Invoke-SmokeTests

foreach ($name in @("successful-build"; "single-root-UI"; )) {
Invoke-VSCodeTest "CMake Tools: $name" `
-TestsPath "$REPO_DIR/out/test/extension-tests/$name" `
-Workspace "$REPO_DIR/test/extension-tests/$name/project-folder"
}

foreach ($name in @("multi-root-UI"; )) {
Invoke-VSCodeTest "CMake Tools: $name" `
-TestsPath "$REPO_DIR/out/test/extension-tests/$name" `
-Workspace "$REPO_DIR/test/extension-tests/$name/project-workspace.code-workspace"
}
}
Invoke-ChronicCommand "yarn lint" $yarn run lint

Invoke-DocsBuild
# Run tests
Invoke-TestPreparation -CMakePath $cmake_binary

$vsce = Find-Program vsce
if (! $vsce) {
Write-Warning "You don't have 'vsce' installed. We won't generate a .vsix package"
}
else {
Invoke-ChronicCommand "Generating VSIX package" $vsce package
}
Invoke-ChronicCommand "yarn pretest" $yarn run pretest
Invoke-ChronicCommand "yarn smokeTests" $yarn run smokeTests
Invoke-ChronicCommand "yarn unitTests" $yarn run unitTests
Invoke-ChronicCommand "yarn extensionTestsSuccessfulBuild" $yarn run extensionTestsSuccessfulBuild
Invoke-ChronicCommand "yarn extensionTestsSingleRoot" $yarn run extensionTestsSingleRoot
Invoke-ChronicCommand "yarn extensionTestsMultioot" $yarn run extensionTestsMultioot
Loading

0 comments on commit 75c91a1

Please sign in to comment.