Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
apupier committed Sep 2, 2022
1 parent 011d081 commit 8439db8
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 16 deletions.
32 changes: 30 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,22 @@
"default": null,
"markdownDescription": "Absolute path to the Vale binary. The predefined [`${workspaceFolder}`](https://code.visualstudio.com/docs/editor/variables-reference#_predefined-variables) variable can be used to reference a non-global binary. (**NOTE**: On Windows you can use '/' and can omit `.cmd` in the path value.)"
},
"vale.valeCLI.usage":{
"scope": "resource",
"type": "string",
"default": "Use Vale CLI specified in vale.valeCLI.path setting",
"enum": ["Use embedded Vale CLI",
"Use Vale CLI specified in vale.valeCLI.path setting",
"Use Vale CLI available from system path"],
"enumDescriptions": ["Use embedded Vale CLI. It is available for Linux, Mac and Windows; all in x64 architectures.",
"Use Vale CLI specified in vale.valeCLI.path setting in priority, if not available fall back to embedded",
"Use Vale CLI available from system path, if not available fall back to embedded"],
"description": "Define which Vale CLI to use. Check the description of each field to have more details in priority order and fallbacks. See Output -> Vale to see if a fallback has been used."
},
"vale.valeCLI.usage": {
"scope": "resource",
"type": "string",
"default": "Use Vale CLI specified in vale.valeCLI.path setting",
"enum": [
"Use embedded Vale CLI",
"Use Vale CLI specified in vale.valeCLI.path setting",
"Use Vale CLI available from system path"
],
"enumDescriptions": [
"Use embedded Vale CLI. It is available for Linux, Mac and Windows; all in x64 architectures.",
"Use Vale CLI specified in vale.valeCLI.path setting in priority, if not available fall back to embedded",
"Use Vale CLI available from system path, if not available fall back to embedded"
],
"description": "Define which Vale CLI to use. Check the description of each field to have more details in priority order and fallbacks. See Output -> Vale to see if a fallback has been used."
},
"vale.minAlertLevel": {
"scope": "resource",
"type": "string",
Expand Down Expand Up @@ -92,6 +96,7 @@
"@types/node": "^18.0.0",
"@types/vscode": "^1.69.0",
"@types/which": "^2.0.1",
"@vscode/test-electron": "^2.1.5",
"glob": "^8.0.3",
"mocha": "^10.0.0",
"ts-loader": "^9.3.1",
Expand All @@ -102,7 +107,7 @@
"webpack-cli": "^4.10.0"
},
"dependencies": {
"which": "^2.0.2",
"fs": "0.0.1-security"
"fs": "0.0.1-security",
"which": "^2.0.2"
}
}
23 changes: 23 additions & 0 deletions src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as path from 'path';

import { runTests } from '@vscode/test-electron';

async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');

// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');

// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}

main();
15 changes: 15 additions & 0 deletions src/test/suite/ProblemDetector.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as assert from 'assert';

// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as myExtension from '../../extension';

suite('Problem reporting', () => {

test('Test basic problem detected', async () => {

assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});
38 changes: 38 additions & 0 deletions src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as path from 'path';
import Mocha from 'mocha';
import glob from 'glob';

export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
color: true
});

const testsRoot = path.resolve(__dirname, '..');

return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}

// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));

try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
});
});
}
1 change: 1 addition & 0 deletions workspace for test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/styles/
7 changes: 7 additions & 0 deletions workspace for test/.vale.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
StylesPath = styles
MinAlertLevel = warning

Packages = write-good

[*]
BasedOnStyles = write-good
2 changes: 2 additions & 0 deletions workspace for test/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The following expression should raise an error detected by write-good pachage:
a chip off the old block

0 comments on commit 8439db8

Please sign in to comment.