From 7ea9f094b56326a98dee1e6d93b12a65d0d4ace4 Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Sun, 25 Aug 2024 20:44:29 +0800 Subject: [PATCH] move grammer fixtures --- extensions/vscode/package.json | 3 +- .../tests/__snapshots__/grammar.spec.ts.snap | 422 ++++++++++++++++++ extensions/vscode/tests/grammar.spec.ts | 13 +- .../vscode/tests/grammarFixtures}/basic.vue | 0 .../tests/grammarFixtures}/directives.vue | 0 .../vscode/tests/grammarFixtures}/generic.vue | 0 .../tests/grammarFixtures}/inline-style.vue | 0 .../vscode/tests/grammarFixtures}/jsx.vue | 0 .../tests/grammarFixtures}/namespaced.vue | 0 .../grammarFixtures}/script-tag-in-script.vue | 0 .../tests/grammarFixtures}/snippet-import.md | 0 .../grammarFixtures}/template-expression.vue | 0 .../grammarFixtures}/template-in-template.vue | 0 package.json | 4 +- pnpm-lock.yaml | 9 +- 15 files changed, 434 insertions(+), 17 deletions(-) rename {test-workspace/grammar => extensions/vscode/tests/grammarFixtures}/basic.vue (100%) rename {test-workspace/language-service/syntax => extensions/vscode/tests/grammarFixtures}/directives.vue (100%) rename {test-workspace/language-service/syntax => extensions/vscode/tests/grammarFixtures}/generic.vue (100%) rename {test-workspace/language-service/syntax => extensions/vscode/tests/grammarFixtures}/inline-style.vue (100%) rename {test-workspace/language-service/syntax => extensions/vscode/tests/grammarFixtures}/jsx.vue (100%) rename {test-workspace/language-service/syntax => extensions/vscode/tests/grammarFixtures}/namespaced.vue (100%) rename {test-workspace/language-service/syntax => extensions/vscode/tests/grammarFixtures}/script-tag-in-script.vue (100%) rename {test-workspace/language-service/syntax => extensions/vscode/tests/grammarFixtures}/snippet-import.md (100%) rename {test-workspace/language-service/syntax => extensions/vscode/tests/grammarFixtures}/template-expression.vue (100%) rename {test-workspace/language-service/syntax => extensions/vscode/tests/grammarFixtures}/template-in-template.vue (100%) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index f8bf2c5aa7..3aefe48ef3 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -556,6 +556,7 @@ "esbuild": "~0.21.0", "esbuild-plugin-copy": "latest", "esbuild-visualizer": "latest", - "semver": "^7.5.4" + "semver": "^7.5.4", + "vscode-tmlanguage-snapshot": "latest" } } diff --git a/extensions/vscode/tests/__snapshots__/grammar.spec.ts.snap b/extensions/vscode/tests/__snapshots__/grammar.spec.ts.snap index 828a4eb916..00f1dbdb3e 100644 --- a/extensions/vscode/tests/__snapshots__/grammar.spec.ts.snap +++ b/extensions/vscode/tests/__snapshots__/grammar.spec.ts.snap @@ -9,3 +9,425 @@ exports[`grammar > basic.vue 1`] = ` # ^^^ source.vue entity.name.tag.div.html.vue # ^ source.vue punctuation.definition.tag.end.html.vue" `; + +exports[`grammar > directives.vue 1`] = ` +"> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^^^ source.vue entity.name.tag.template.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue +> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^^^ source.vue entity.name.tag.template.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue +> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^^^ source.vue entity.name.tag.template.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue +> +#^ source.vue punctuation.definition.tag.begin.html.vue +# ^ source.vue +# ^^ source.vue entity.name.tag.--.html.vue +# ^^^^^^^^ source.vue meta.tag-stuff +# ^ source.vue meta.tag-stuff punctuation.definition.tag.end.html.vue +> +#^^^^^^^^^^^ source.vue +> +#^ source.vue text" +`; + +exports[`grammar > generic.vue 1`] = ` +"> +#^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^ source.vue entity.name.tag.script.html.vue +# ^^^^^^^ source.vue meta.tag-stuff +# ^^^^^^^ source.vue meta.tag-stuff meta.attribute.generic.vue entity.other.attribute-name.html.vue +# ^ source.vue meta.tag-stuff meta.attribute.generic.vue punctuation.separator.key-value.html.vue +# ^ source.vue meta.tag-stuff meta.attribute.generic.vue meta.type.parameters.vue punctuation.definition.string.begin.html.vue +# ^ source.vue meta.tag-stuff meta.attribute.generic.vue meta.type.parameters.vue +# ^ source.vue meta.tag-stuff meta.attribute.generic.vue meta.type.parameters.vue punctuation.definition.string.end.html.vue +# ^ source.vue meta.tag-stuff punctuation.definition.tag.end.html.vue +# ^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^ source.vue entity.name.tag.script.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue" +`; + +exports[`grammar > inline-style.vue 1`] = ` +"> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^^^ source.vue entity.name.tag.template.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue +> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^^^ source.vue entity.name.tag.template.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue" +`; + +exports[`grammar > jsx.vue 1`] = ` +"> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^ source.vue entity.name.tag.script.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue +> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^ source.vue entity.name.tag.script.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue" +`; + +exports[`grammar > namespaced.vue 1`] = ` +"> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^ source.vue entity.name.tag.script.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue +> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^^^ source.vue entity.name.tag.template.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue" +`; + +exports[`grammar > script-tag-in-script.vue 1`] = ` +">' +#^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^ source.vue entity.name.tag.script.html.vue +# ^ source.vue meta.tag-stuff punctuation.definition.tag.end.html.vue +# ^^^^^^^^^ source.vue +# ^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^ source.vue entity.name.tag.script.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +# ^ source.vue +# ^ source.vue punctuation.definition.tag.begin.html.vue +# ^ source.vue +# ^^^^^^ source.vue entity.name.tag.script.html.vue +# ^ source.vue meta.tag-stuff punctuation.definition.tag.end.html.vue +> +#^ source.vue" +`; + +exports[`grammar > template-expression.vue 1`] = ` +"> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^^^ source.vue entity.name.tag.template.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue" +`; + +exports[`grammar > template-in-template.vue 1`] = ` +"> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^^^ source.vue entity.name.tag.template.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue +> +#^^ source.vue punctuation.definition.tag.begin.html.vue +# ^^^^^^^^ source.vue entity.name.tag.template.html.vue +# ^ source.vue punctuation.definition.tag.end.html.vue +> +#^ source.vue" +`; diff --git a/extensions/vscode/tests/grammar.spec.ts b/extensions/vscode/tests/grammar.spec.ts index 0c5e7068ee..4790ba6431 100644 --- a/extensions/vscode/tests/grammar.spec.ts +++ b/extensions/vscode/tests/grammar.spec.ts @@ -1,19 +1,18 @@ import * as path from 'path'; -import * as _fg from 'fast-glob'; +import * as fs from 'fs'; import { describe, expect, it } from 'vitest'; import { createGrammarSnapshot } from 'vscode-tmlanguage-snapshot'; -const fg: typeof _fg = (_fg as any).default; -const fixturesDir = path.resolve(__dirname, '../../../test-workspace/grammar'); +const fixturesDir = path.resolve(__dirname, './grammarFixtures'); const packageJsonPath = path.resolve(__dirname, '../package.json'); describe('grammar', async () => { const snapshot = await createGrammarSnapshot(packageJsonPath); - const cases = await fg(path.join(fixturesDir, "**").replace(/\\/g, "/")); + const fixtures = fs.readdirSync(fixturesDir); - for (const kase of cases) { - it(path.relative(fixturesDir, kase).replace(/\\/g, "/"), async () => { - const result = await snapshot(kase); + for (const fixture of fixtures) { + it.skipIf(fixture === 'snippet-import.md')(fixture, async () => { + const result = await snapshot(`tests/grammarFixtures/${fixture}`); expect(result).toMatchSnapshot(); }); diff --git a/test-workspace/grammar/basic.vue b/extensions/vscode/tests/grammarFixtures/basic.vue similarity index 100% rename from test-workspace/grammar/basic.vue rename to extensions/vscode/tests/grammarFixtures/basic.vue diff --git a/test-workspace/language-service/syntax/directives.vue b/extensions/vscode/tests/grammarFixtures/directives.vue similarity index 100% rename from test-workspace/language-service/syntax/directives.vue rename to extensions/vscode/tests/grammarFixtures/directives.vue diff --git a/test-workspace/language-service/syntax/generic.vue b/extensions/vscode/tests/grammarFixtures/generic.vue similarity index 100% rename from test-workspace/language-service/syntax/generic.vue rename to extensions/vscode/tests/grammarFixtures/generic.vue diff --git a/test-workspace/language-service/syntax/inline-style.vue b/extensions/vscode/tests/grammarFixtures/inline-style.vue similarity index 100% rename from test-workspace/language-service/syntax/inline-style.vue rename to extensions/vscode/tests/grammarFixtures/inline-style.vue diff --git a/test-workspace/language-service/syntax/jsx.vue b/extensions/vscode/tests/grammarFixtures/jsx.vue similarity index 100% rename from test-workspace/language-service/syntax/jsx.vue rename to extensions/vscode/tests/grammarFixtures/jsx.vue diff --git a/test-workspace/language-service/syntax/namespaced.vue b/extensions/vscode/tests/grammarFixtures/namespaced.vue similarity index 100% rename from test-workspace/language-service/syntax/namespaced.vue rename to extensions/vscode/tests/grammarFixtures/namespaced.vue diff --git a/test-workspace/language-service/syntax/script-tag-in-script.vue b/extensions/vscode/tests/grammarFixtures/script-tag-in-script.vue similarity index 100% rename from test-workspace/language-service/syntax/script-tag-in-script.vue rename to extensions/vscode/tests/grammarFixtures/script-tag-in-script.vue diff --git a/test-workspace/language-service/syntax/snippet-import.md b/extensions/vscode/tests/grammarFixtures/snippet-import.md similarity index 100% rename from test-workspace/language-service/syntax/snippet-import.md rename to extensions/vscode/tests/grammarFixtures/snippet-import.md diff --git a/test-workspace/language-service/syntax/template-expression.vue b/extensions/vscode/tests/grammarFixtures/template-expression.vue similarity index 100% rename from test-workspace/language-service/syntax/template-expression.vue rename to extensions/vscode/tests/grammarFixtures/template-expression.vue diff --git a/test-workspace/language-service/syntax/template-in-template.vue b/extensions/vscode/tests/grammarFixtures/template-in-template.vue similarity index 100% rename from test-workspace/language-service/syntax/template-in-template.vue rename to extensions/vscode/tests/grammarFixtures/template-in-template.vue diff --git a/package.json b/package.json index c82836a9d0..2e95edd2db 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,9 @@ "@tsslint/cli": "latest", "@tsslint/config": "latest", "@volar/language-service": "~2.4.0", - "fast-glob": "^3.3.2", "typescript": "latest", "vite": "latest", - "vitest": "latest", - "vscode-tmlanguage-snapshot": "^0.1.3" + "vitest": "latest" }, "pnpm": { "overrides": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c54d2af350..866131ace8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,9 +35,6 @@ importers: '@volar/language-service': specifier: https://pkg.pr.new/volarjs/volar.js/@volar/language-service@28cbdee version: https://pkg.pr.new/volarjs/volar.js/@volar/language-service@28cbdee - fast-glob: - specifier: ^3.3.2 - version: 3.3.2 typescript: specifier: latest version: 5.5.3 @@ -47,9 +44,6 @@ importers: vitest: specifier: latest version: 2.0.3(@types/node@20.14.11) - vscode-tmlanguage-snapshot: - specifier: ^0.1.3 - version: 0.1.3 extensions/vscode: devDependencies: @@ -86,6 +80,9 @@ importers: semver: specifier: ^7.5.4 version: 7.6.2 + vscode-tmlanguage-snapshot: + specifier: latest + version: 0.1.3 packages/component-meta: dependencies: