Skip to content

Commit

Permalink
Adding testing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoslund committed Nov 5, 2019
1 parent a1e6a83 commit e5d79e7
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 23 deletions.
5 changes: 3 additions & 2 deletions dotnetcore-acquisition-extension/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
"preLaunchTask": "npm: watch"
},
{
"name": "Extension Acquisition Tests",
"name": "Extension Acquisition Functional Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
"--extensionTestsPath=${workspaceFolder}/out/test/functional"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "npm: watch"
}
]
Expand Down
19 changes: 11 additions & 8 deletions dotnetcore-acquisition-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dotnetcore-acquisition",
"repository": {
"type": "git",
"url": "https://github.com/NTaylorMullen/vscode-dotnetcore-acquisition-extension.git"
"url": "https://github.com/dotnet/vscode-dotnetcore-acquisition-extension.git"
},
"displayName": "DotnetCoreAcquisition",
"description": "An extension to acquire .NET Core tooling to run .NET Core applications in Visual Studio Code extensions.",
Expand All @@ -26,20 +26,23 @@
"vscode:prepublish": "npm run compile",
"compile": "npm run clean && tsc -p ./",
"watch": "npm run compile && tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "npm run compile && node ./node_modules/vscode/bin/test",
"test": "npm run compile --silent && node ./out/test/functional/runTest.js",
"clean": "rimraf out"
},
"dependencies": {
"dotnetcore-acquisition-library": "file:../dotnetcore-acquisition-library"
},
"devDependencies": {
"@types/mocha": "5.2.6",
"@types/node": "12.0.0",
"@types/rimraf": "2.0.2",
"@types/vscode": "^1.33.0",
"chai": "^4.2.0",
"glob": "^7.1.5",
"mocha": "^4.1.0",
"rimraf": "2.6.3",
"typescript": "3.4.5",
"vscode": "1.1.34",
"tslint": "5.16.0",
"@types/node": "12.0.0",
"@types/mocha": "5.2.6",
"@types/rimraf": "2.0.2"
"typescript": "3.4.5",
"vscode-test": "^1.2.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ suite('Extension End to End', () => {
// const context: vscode.ExtensionContext = {
// subscriptions: [],
// } as any;
// extension.activate(context, "");
// extension.activate(context);
// assert.equals(context.subscriptions.length, 1);
});
});
Empty file.
Empty file.
6 changes: 3 additions & 3 deletions dotnetcore-acquisition-library/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
{
"type": "node",
"request": "launch",
"name": "Acquisistion Worker Tests",
"name": "Acquisistion Worker Unit Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"tdd",
"--no-timeout",
"--colors",
"${workspaceFolder}/dist/test/**.test.js"
"${workspaceFolder}/dist/test/unit/**.test.js"
],
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "compile"
"preLaunchTask": "npm: watch"
}
]
}
10 changes: 7 additions & 3 deletions dotnetcore-acquisition-library/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
"version": "2.0.0",
"tasks": [
{
"label": "compile",
"type": "npm",
"script": "compile",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
}
3 changes: 1 addition & 2 deletions dotnetcore-acquisition-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"vscode:prepublish": "npm run compile",
"compile": "npm run clean && tsc -p ./",
"watch": "npm run clean && tsc -watch -p ./",
"test": "npm run compile && npm run unit-test && npm run functional-test",
"functional-test": "node ./dist/test/functional/runTest.js",
"test": "npm run compile --silent && npm run unit-test",
"unit-test": "mocha -u tdd -- dist/test/unit/**.test.js",
"clean": "rimraf dist"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ suite("DotnetCoreAcquisitionWorker Unit Tests", function () {
assert.isEmpty(fs.readdirSync(TestUtils.testStorage));
}).timeout(20000);

after(function() {
this.afterAll(function() {
// Clean up temp storage
rimraf.sync(TestUtils.testStorage);
});
Expand Down
5 changes: 2 additions & 3 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"vscode:prepublish": "npm run compile",
"compile": "npm run clean && tsc -p ./",
"watch": "npm run clean && tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "npm run compile && node ./node_modules/vscode/bin/test",
"clean": "rimraf out"
},
Expand All @@ -61,10 +60,10 @@
"devDependencies": {
"rimraf": "2.6.3",
"typescript": "3.4.5",
"vscode": "1.1.34",
"tslint": "5.16.0",
"@types/node": "12.0.0",
"@types/mocha": "5.2.6",
"@types/rimraf": "2.0.2"
"@types/rimraf": "2.0.2",
"@types/vscode": "^1.33.0"
}
}
2 changes: 2 additions & 0 deletions test.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0test.ps1' default-build %*; exit $LASTEXITCODE"
46 changes: 46 additions & 0 deletions test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
$result = 0
$errorColor = "Red"
$successColor = "Green"

pushd dotnetcore-acquisition-library
if (Test-Path node_modules) { rm -r -force node_modules }
npm install --silent
npm run test

if (! $?)
{
Write-Host "`nAcquisition Library Tests Failed.`n" -ForegroundColor $errorColor
$result = 1
}
else
{
Write-Host "`nAcquisition Library Tests Succeeded.`n" -ForegroundColor $successColor
}
popd

pushd dotnetcore-acquisition-extension
if (Test-Path node_modules) { rm -r -force node_modules }
npm install --silent
npm run test

if (! $?)
{
Write-Host "`nAcquisition Extension Tests Failed.`n" -ForegroundColor $errorColor
$result = 1
}
else
{
Write-Host "`nAcquisition Extension Tests Succeeded.`n" -ForegroundColor $successColor
}
popd

if ($result -ne 0)
{
Write-Host "`n`nTests Failed.`n" -ForegroundColor $errorColor
exit $result
}
else
{
Write-Host "`n`nAll Tests Succeeded.`n" -ForegroundColor $successColor
exit $result
}
61 changes: 61 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
RESULT=0
RED=`tput setaf 1`
GREEN=`tput setaf 2`
NC=`tput sgr0`

echo ""
echo "----------- Testing dotnetcore-acquisition-library -----------"
echo ""
pushd dotnetcore-acquisition-library
rm -rf node_modules
npm install
npm run test

if [ $? -ne 0 ];
then
echo ""
echo "${RED}Acquisition Library Tests Failed.${NC}"
echo ""
RESULT=1
else
echo ""
echo "${GREEN}Acquisition Library Tests Succeeded.${NC}"
echo ""
fi
popd

echo ""
echo "----------- Testing dotnetcore-acquisition-extension -----------"
echo ""
pushd dotnetcore-acquisition-extension
rm -rf node_modules
npm install
npm run test

if [ $? -ne 0 ];
then
echo ""
echo "${RED}Acquisition Extension Tests Failed.${NC}"
echo ""
RESULT=1
else
echo ""
echo "${GREEN}Acquisition Extension Tests Succeeded.${NC}"
echo ""
fi
popd

if [ $RESULT -ne 0 ];
then
echo ""
echo ""
echo "${RED}Tests Failed.${NC}"
echo ""
exit $RESULT
else
echo ""
echo ""
echo "${GREEN}All Tests Succeeded.${NC}"
echo ""
exit $RESULT
fi

0 comments on commit e5d79e7

Please sign in to comment.