From 968249d8c5e305f9ef128d5ff2b4578c39cb0779 Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Fri, 14 Jun 2024 13:08:37 +0200 Subject: [PATCH 1/6] test(client): setup e2e tests for diagnostics --- client/package.json | 3 +- client/src/test/completion.test.ts | 68 ++--- client/src/test/diagnostics.test.ts | 74 ++++-- client/src/test/helper.ts | 39 +-- client/src/test/index.ts | 42 ++-- .../diagnostics-expressions.publicodes | 5 + .../testFixture/diagnostics-import.publicodes | 11 + client/testFixture/diagnostics.txt | 1 - client/testFixture/main.publicodes | 5 + client/tsconfig.json | 13 +- client/yarn.lock | 233 ++++++++++++++++++ language-configuration.json | 2 +- package.json | 4 +- 13 files changed, 395 insertions(+), 105 deletions(-) create mode 100644 client/testFixture/diagnostics-expressions.publicodes create mode 100644 client/testFixture/diagnostics-import.publicodes delete mode 100644 client/testFixture/diagnostics.txt create mode 100644 client/testFixture/main.publicodes diff --git a/client/package.json b/client/package.json index 3b202b7..abeffab 100644 --- a/client/package.json +++ b/client/package.json @@ -17,6 +17,7 @@ }, "devDependencies": { "@types/vscode": "^1.75.1", - "@vscode/test-electron": "^2.2.3" + "@vscode/test-electron": "^2.2.3", + "glob": "^10.4.1" } } diff --git a/client/src/test/completion.test.ts b/client/src/test/completion.test.ts index b11afdd..0fcb6f3 100644 --- a/client/src/test/completion.test.ts +++ b/client/src/test/completion.test.ts @@ -7,37 +7,37 @@ import * as vscode from "vscode"; import * as assert from "assert"; import { getDocUri, activate } from "./helper"; -suite("Should do completion", () => { - const docUri = getDocUri("completion.txt"); - - test("Completes JS/TS in txt file", async () => { - await testCompletion(docUri, new vscode.Position(0, 0), { - items: [ - { label: "JavaScript", kind: vscode.CompletionItemKind.Text }, - { label: "TypeScript", kind: vscode.CompletionItemKind.Text }, - ], - }); - }); -}); - -async function testCompletion( - docUri: vscode.Uri, - position: vscode.Position, - expectedCompletionList: vscode.CompletionList, -) { - await activate(docUri); - - // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion - const actualCompletionList = (await vscode.commands.executeCommand( - "vscode.executeCompletionItemProvider", - docUri, - position, - )) as vscode.CompletionList; - - assert.ok(actualCompletionList.items.length >= 2); - expectedCompletionList.items.forEach((expectedItem, i) => { - const actualItem = actualCompletionList.items[i]; - assert.equal(actualItem.label, expectedItem.label); - assert.equal(actualItem.kind, expectedItem.kind); - }); -} +// suite("Should do completion", () => { +// const docUri = getDocUri("completion.txt"); +// +// test("Completes JS/TS in txt file", async () => { +// await testCompletion(docUri, new vscode.Position(0, 0), { +// items: [ +// { label: "JavaScript", kind: vscode.CompletionItemKind.Text }, +// { label: "TypeScript", kind: vscode.CompletionItemKind.Text }, +// ], +// }); +// }); +// }); +// +// async function testCompletion( +// docUri: vscode.Uri, +// position: vscode.Position, +// expectedCompletionList: vscode.CompletionList, +// ) { +// await activate(docUri); +// +// // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion +// const actualCompletionList = (await vscode.commands.executeCommand( +// "vscode.executeCompletionItemProvider", +// docUri, +// position, +// )) as vscode.CompletionList; +// +// assert.ok(actualCompletionList.items.length >= 2); +// expectedCompletionList.items.forEach((expectedItem, i) => { +// const actualItem = actualCompletionList.items[i]; +// assert.equal(actualItem.label, expectedItem.label); +// assert.equal(actualItem.kind, expectedItem.kind); +// }); +// } diff --git a/client/src/test/diagnostics.test.ts b/client/src/test/diagnostics.test.ts index b2477d6..3ce5407 100644 --- a/client/src/test/diagnostics.test.ts +++ b/client/src/test/diagnostics.test.ts @@ -1,34 +1,58 @@ -/* -------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * ------------------------------------------------------------------------------------------ */ - import * as vscode from "vscode"; import * as assert from "assert"; -import { getDocUri, activate } from "./helper"; +import { getDocUri, activate, mainUri, mainPath } from "./helper"; -suite("Should get diagnostics", () => { - const docUri = getDocUri("diagnostics.txt"); +/** + * End-to-end test suite for diagnostics. + * + * How it works: + * 1. Start a vscode instance. + * 2. Activate the 'publicodes-language-server' extension in the instance. + * 3. Open the main document (main.publicodes). + * 4. For each test: + * a. copy the content of the test document to the main document, + * b. save the main document and wait for the diagnostics to be computed. + */ - test("Diagnoses uppercase texts", async () => { - await testDiagnostics(docUri, [ - { - message: "ANY is all uppercase.", - range: toRange(0, 0, 0, 3), - severity: vscode.DiagnosticSeverity.Warning, - source: "ex", - }, +suite("Should get diagnostics", () => { + test("Missing name in import macros", async () => { + await testDiagnostics(getDocUri("diagnostics-import.publicodes"), [ { - message: "ANY is all uppercase.", - range: toRange(0, 14, 0, 17), - severity: vscode.DiagnosticSeverity.Warning, - source: "ex", + message: `[ Erreur dans la macro 'importer!' ] +Le nom du package est manquant dans la macro 'importer!' dans le fichier: ${mainPath}. + +[ Solution ] +Ajoutez le nom du package dans la macro 'importer!'. + +[ Exemple ] +importer!: + depuis: + nom: package-name + les règles: + - ruleA + - ruleB + ... +`, + range: toRange(0, 0, 0, 9), + severity: vscode.DiagnosticSeverity.Error, + source: "publicodes", }, + ]); + }); + + test("Malformed expression", async () => { + await testDiagnostics(getDocUri("diagnostics-expressions.publicodes"), [ { - message: "OS is all uppercase.", - range: toRange(0, 18, 0, 20), - severity: vscode.DiagnosticSeverity.Warning, - source: "ex", + message: `[ InternalError ] +➡️ Dans la règle "logement . électricité . photovoltaique" +✖️ +Un problème est survenu lors du parsing de l'expression \`autoconsommation + production +\` : + + le parseur Nearley n'a pas réussi à parser l'expression. +`, + range: toRange(0, 0, 0, 39), + severity: vscode.DiagnosticSeverity.Error, + source: "publicodes", }, ]); }); @@ -46,7 +70,7 @@ async function testDiagnostics( ) { await activate(docUri); - const actualDiagnostics = vscode.languages.getDiagnostics(docUri); + const actualDiagnostics = vscode.languages.getDiagnostics(mainUri); assert.equal(actualDiagnostics.length, expectedDiagnostics.length); diff --git a/client/src/test/helper.ts b/client/src/test/helper.ts index 47910c9..31bff3c 100644 --- a/client/src/test/helper.ts +++ b/client/src/test/helper.ts @@ -1,8 +1,3 @@ -/* -------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * ------------------------------------------------------------------------------------------ */ - import * as vscode from "vscode"; import * as path from "path"; @@ -11,20 +6,28 @@ export let editor: vscode.TextEditor; export let documentEol: string; export let platformEol: string; -/** - * Activates the vscode.lsp-sample extension - */ +export async function initialize() { + doc = await vscode.workspace.openTextDocument(mainUri); + editor = await vscode.window.showTextDocument(doc); +} + export async function activate(docUri: vscode.Uri) { // The extensionId is `publisher.name` from package.json - const ext = vscode.extensions.getExtension("vscode-samples.lsp-sample")!; - await ext.activate(); - try { - doc = await vscode.workspace.openTextDocument(docUri); - editor = await vscode.window.showTextDocument(doc); - await sleep(2000); // Wait for server activation - } catch (e) { - console.error(e); + const ext = vscode.extensions.getExtension( + "EmileRolley.publicodes-language-server", + )!; + if (!ext.isActive) { + await ext.activate(); + try { + await initialize(); + } catch (e) { + console.error(e); + } } + const content = await vscode.workspace.fs.readFile(docUri); + await setTestContent(content.toString()); + await vscode.workspace.saveAll(); + await sleep(500); // Wait for server activation } async function sleep(ms: number) { @@ -34,10 +37,14 @@ async function sleep(ms: number) { export const getDocPath = (p: string) => { return path.resolve(__dirname, "../../testFixture", p); }; + export const getDocUri = (p: string) => { return vscode.Uri.file(getDocPath(p)); }; +export const mainPath = "main.publicodes"; +export const mainUri = getDocUri(mainPath); + export async function setTestContent(content: string): Promise { const all = new vscode.Range( doc.positionAt(0), diff --git a/client/src/test/index.ts b/client/src/test/index.ts index 417e9e7..490be7a 100644 --- a/client/src/test/index.ts +++ b/client/src/test/index.ts @@ -4,7 +4,7 @@ * ------------------------------------------------------------------------------------------ */ import * as path from "path"; import Mocha from "mocha"; -import * as glob from "glob"; +import { glob } from "glob"; export function run(): Promise { // Create the mocha test @@ -17,27 +17,25 @@ export function run(): Promise { const testsRoot = __dirname; return new Promise((resolve, reject) => { - glob("**.test.js", { cwd: testsRoot }, (err, files) => { - if (err) { - return reject(err); - } + glob("**.test.js", { cwd: testsRoot }) + .then((files) => { + // Add files to the test suite + files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); - // 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) { - reject(new Error(`${failures} tests failed.`)); - } else { - resolve(); - } - }); - } catch (err) { - console.error(err); - reject(err); - } - }); + try { + // Run the mocha test + mocha.run((failures) => { + if (failures > 0) { + reject(new Error(`${failures} tests failed.`)); + } else { + resolve(); + } + }); + } catch (err) { + console.error(err); + reject(err); + } + }) + .catch(reject); }); } diff --git a/client/testFixture/diagnostics-expressions.publicodes b/client/testFixture/diagnostics-expressions.publicodes new file mode 100644 index 0000000..ad5abfc --- /dev/null +++ b/client/testFixture/diagnostics-expressions.publicodes @@ -0,0 +1,5 @@ +logement . électricité . photovoltaique: + titre: Panneaux photovoltaïques + formule: + somme: + - autoconsommation + production + diff --git a/client/testFixture/diagnostics-import.publicodes b/client/testFixture/diagnostics-import.publicodes new file mode 100644 index 0000000..f6795be --- /dev/null +++ b/client/testFixture/diagnostics-import.publicodes @@ -0,0 +1,11 @@ +importer!: + depuis: + # nom: '@incubateur-ademe/publicodes-commun' + url: https://github.com/incubateur-ademe/publicodes-commun + dans: commun + les règles: + - intensité électricité + - mois par an + - semaines par an + - jours par semaine + - jours par an diff --git a/client/testFixture/diagnostics.txt b/client/testFixture/diagnostics.txt deleted file mode 100644 index d910cfb..0000000 --- a/client/testFixture/diagnostics.txt +++ /dev/null @@ -1 +0,0 @@ -ANY browsers, ANY OS. \ No newline at end of file diff --git a/client/testFixture/main.publicodes b/client/testFixture/main.publicodes new file mode 100644 index 0000000..ad5abfc --- /dev/null +++ b/client/testFixture/main.publicodes @@ -0,0 +1,5 @@ +logement . électricité . photovoltaique: + titre: Panneaux photovoltaïques + formule: + somme: + - autoconsommation + production + diff --git a/client/tsconfig.json b/client/tsconfig.json index 17f74b2..bc43804 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -3,13 +3,20 @@ "module": "nodenext", "target": "es2021", "esModuleInterop": true, - "lib": ["es2021"], + "lib": [ + "es2021" + ], "outDir": "out", "rootDir": "src", "sourceMap": true, "composite": true, "incremental": true }, - "include": ["src"], - "exclude": ["node_modules", ".vscode-test"] + "include": [ + "src" + ], + "exclude": [ + "node_modules", + ".vscode-test" + ] } diff --git a/client/yarn.lock b/client/yarn.lock index dfca6fd..5d764c7 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -2,6 +2,23 @@ # yarn lockfile v1 +"@isaacs/cliui@^8.0.2": + version "8.0.2" + resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" + integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== + dependencies: + string-width "^5.1.2" + string-width-cjs "npm:string-width@^4.2.0" + strip-ansi "^7.0.1" + strip-ansi-cjs "npm:strip-ansi@^6.0.1" + wrap-ansi "^8.1.0" + wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" + +"@pkgjs/parseargs@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" + integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== + "@tootallnate/once@1": version "1.1.2" resolved "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz" @@ -29,6 +46,28 @@ agent-base@6: dependencies: debug "4" +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + +ansi-styles@^4.0.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +ansi-styles@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz" @@ -41,11 +80,32 @@ brace-expansion@^2.0.1: dependencies: balanced-match "^1.0.0" +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + core-util-is@~1.0.0: version "1.0.3" resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz" integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== +cross-spawn@^7.0.0: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + debug@4: version "4.3.4" resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz" @@ -53,6 +113,40 @@ debug@4: dependencies: ms "2.1.2" +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + +foreground-child@^3.1.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.2.0.tgz#5eb496c4ebf3bcc4572e8908a45a72f5a1d2d658" + integrity sha512-CrWQNaEl1/6WeZoarcM9LHupTo3RpZO2Pdk1vktwzPiQTsJnAKJmm3TACKeG5UZbWDfaH2AbvYxzP96y0MT7fA== + dependencies: + cross-spawn "^7.0.0" + signal-exit "^4.0.1" + +glob@^10.4.1: + version "10.4.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.1.tgz#0cfb01ab6a6b438177bfe6a58e2576f6efe909c2" + integrity sha512-2jelhlq3E4ho74ZyVLN03oKdAZVUa6UDZzFLVH1H7dnoax+y9qyaq8zBkfDIggjniU19z0wU18y16jMB2eyVIw== + dependencies: + foreground-child "^3.1.0" + jackspeak "^3.1.2" + minimatch "^9.0.4" + minipass "^7.1.2" + path-scurry "^1.11.1" + http-proxy-agent@^4.0.1: version "4.0.1" resolved "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz" @@ -80,11 +174,30 @@ inherits@~2.0.3: resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + isarray@~1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +jackspeak@^3.1.2: + version "3.4.0" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.0.tgz#a75763ff36ad778ede6a156d8ee8b124de445b4a" + integrity sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw== + dependencies: + "@isaacs/cliui" "^8.0.2" + optionalDependencies: + "@pkgjs/parseargs" "^0.11.0" + jszip@^3.10.1: version "3.10.1" resolved "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz" @@ -102,6 +215,11 @@ lie@~3.3.0: dependencies: immediate "~3.0.5" +lru-cache@^10.2.0: + version "10.2.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878" + integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== + lru-cache@^6.0.0: version "6.0.0" resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz" @@ -116,6 +234,18 @@ minimatch@^5.1.0: dependencies: brace-expansion "^2.0.1" +minimatch@^9.0.4: + version "9.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51" + integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw== + dependencies: + brace-expansion "^2.0.1" + +"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707" + integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw== + ms@2.1.2: version "2.1.2" resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" @@ -126,6 +256,19 @@ pako@~1.0.2: resolved "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz" integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +path-scurry@^1.11.1: + version "1.11.1" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2" + integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA== + dependencies: + lru-cache "^10.2.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz" @@ -161,6 +304,50 @@ setimmediate@^1.0.5: resolved "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz" integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA== +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +signal-exit@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz" @@ -168,6 +355,27 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + dependencies: + ansi-regex "^6.0.1" + util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" @@ -200,6 +408,31 @@ vscode-languageserver-types@3.17.3: resolved "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz" integrity sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA== +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrap-ansi@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== + dependencies: + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" + yallist@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz" diff --git a/language-configuration.json b/language-configuration.json index b6c10f5..d485549 100644 --- a/language-configuration.json +++ b/language-configuration.json @@ -35,7 +35,7 @@ "wordPattern": "(^.?[^\\s]+)+|([^\\s\n={[][\\w\\-\\./$%&*:\"']+)", "onEnterRules": [ { - "beforeText": "^\\s*(moyenne|somme|une de ces conditions|toutes ces conditions|variations|le maximum de|le minimum de|suggestions|références)\\:\\s*$", + "beforeText": "^\\s*(moyenne|somme|une de ces conditions|toutes ces conditions|variations|le maximum de|le minimum de|suggestions|références|les règles)\\:\\s*$", "action": { "indent": "indent", "appendText": "- " diff --git a/package.json b/package.json index e25008f..9b67c7e 100644 --- a/package.json +++ b/package.json @@ -23,11 +23,11 @@ "main": "./client/out/extension", "scripts": { "deploy": "vsce publish --yarn", - "compile": "tsc -b && tsc-alias -p server/tsconfig.json", + "compile": "tsc -b server && tsc -b client && tsc-alias -p server/tsconfig.json", "dev": "concurrently \"tsc -b -w\" \"tsc-alias -p server/tsconfig.json -w\"", "lint": "eslint ./client/src ./server/src --ext .ts,.tsx", "postinstall": "yarn install --cwd client && yarn install --cwd server", - "test": "sh ./scripts/e2e.sh", + "test": "yarn run compile && sh ./scripts/e2e.sh", "format": "prettier --write .", "format:check": "prettier --check . server client", "postversion": "git push --tags && git push" From fa9a60eb9d3b71187d3606d763f8cca16f2527ab Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Fri, 14 Jun 2024 13:36:13 +0200 Subject: [PATCH 2/6] ci: setup tests on all main OS --- .github/workflows/compile.yml | 10 ++++++---- client/tsconfig.json | 13 +++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index fa6ab59..880c763 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -10,7 +10,10 @@ on: jobs: main: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -22,9 +25,8 @@ jobs: - name: Build package run: yarn compile - # TODO: Uncomment the following lines if you have tests - # - name: Test the package - # run: yarn test + - name: Test the package + run: yarn test - name: Check file formatting run: yarn format:check diff --git a/client/tsconfig.json b/client/tsconfig.json index bc43804..17f74b2 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -3,20 +3,13 @@ "module": "nodenext", "target": "es2021", "esModuleInterop": true, - "lib": [ - "es2021" - ], + "lib": ["es2021"], "outDir": "out", "rootDir": "src", "sourceMap": true, "composite": true, "incremental": true }, - "include": [ - "src" - ], - "exclude": [ - "node_modules", - ".vscode-test" - ] + "include": ["src"], + "exclude": ["node_modules", ".vscode-test"] } From b831fcdea838d47322e99b08bd40eb61fbac913c Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Fri, 14 Jun 2024 13:45:20 +0200 Subject: [PATCH 3/6] ci: run tests with xvfb-run on linux --- .github/workflows/compile.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 880c763..97711ef 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -25,8 +25,13 @@ jobs: - name: Build package run: yarn compile - - name: Test the package + - name: Test the package (Linux) + run: xvfb-run -a npm test + if: runner.os == 'Linux' + + - name: Test the package (Others) run: yarn test + if: runner.os != 'Linux' - name: Check file formatting run: yarn format:check From 54ddd1df4bbcd02106cc5e3fde81ab944e86fbaf Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Fri, 14 Jun 2024 14:02:21 +0200 Subject: [PATCH 4/6] ci: only run tests on Linux --- .github/workflows/compile.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 97711ef..4fe8dcf 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -10,10 +10,7 @@ on: jobs: main: - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -25,13 +22,9 @@ jobs: - name: Build package run: yarn compile - - name: Test the package (Linux) + - name: Test the package run: xvfb-run -a npm test if: runner.os == 'Linux' - - name: Test the package (Others) - run: yarn test - if: runner.os != 'Linux' - - name: Check file formatting run: yarn format:check From 9fb9d47388ca9998e3d6da8bcce3c0add434798c Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Fri, 14 Jun 2024 14:46:32 +0200 Subject: [PATCH 5/6] ci: try to use the vsce package command --- .github/workflows/publish.yml | 6 ++++-- package.json | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 45795c9..54c8534 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,8 +19,10 @@ jobs: registry-url: https://registry.npmjs.org/ node-version: 20.x cache: yarn - - run: yarn install --immutable - - run: yarn run compile + - name: Install dependencies + run: yarn install --immutable + - name: Build package + run: npx vsce package - uses: softprops/action-gh-release@v2 with: generate_release_notes: true diff --git a/package.json b/package.json index 9b67c7e..3828a5b 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "test": "yarn run compile && sh ./scripts/e2e.sh", "format": "prettier --write .", "format:check": "prettier --check . server client", - "postversion": "git push --tags && git push" + "postversion": "git push --tags && git push", + "vscode:prepublish": "yarn run compile" }, "activationEvents": [ "onLanguage:publicodes" From 171e05329d9ef5f1272115821a1c43c02a097770 Mon Sep 17 00:00:00 2001 From: Emile Rolley Date: Fri, 14 Jun 2024 14:52:48 +0200 Subject: [PATCH 6/6] v0.7.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3828a5b..80d06d5 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "icon": "icons/publicodes-logo.png", "author": "Emile Rolley ", "license": "MIT", - "version": "0.7.9", + "version": "0.7.10", "publisher": "EmileRolley", "repository": { "type": "git",