Skip to content

Commit 71d03f6

Browse files
chore: enable snapshot integration test (#30)
This will enable the snapshot integration tests.
1 parent c91a15f commit 71d03f6

File tree

112 files changed

+11576
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+11576
-3
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
issues: write
15+
pull-requests: write
1216
steps:
13-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1418

1519
- uses: actions/setup-node@v3
1620
with:
@@ -21,3 +25,42 @@ jobs:
2125

2226
- name: Run tests
2327
run: npm test
28+
29+
- name: Update snapshot
30+
run: npm run update-snapshot && git add --all
31+
32+
- name: Prepare diff for comment
33+
id: diff
34+
continue-on-error: true
35+
run: |
36+
set +e
37+
body=$(git diff --exit-code --diff-filter=AM $GITHUB_SHA -- '*.snap' 2>&1)
38+
echo "exitcode=$?" >> $GITHUB_OUTPUT
39+
body="${body//'<'/'&lt;'}"
40+
body="${body//'>'/'&gt;'}"
41+
delimiter="$(openssl rand -hex 8)"
42+
echo "body<<${delimiter}" >> $GITHUB_OUTPUT
43+
echo "${body:0:64000}" >> $GITHUB_OUTPUT
44+
echo "${delimiter}" >> $GITHUB_OUTPUT
45+
- uses: marocchino/sticky-pull-request-comment@v2
46+
if: github.event_name == 'pull_request' && steps.diff.outputs.exitcode == '1'
47+
with:
48+
header: sticky-comment-for-git-diff
49+
hide_and_recreate: true
50+
hide_classify: "OUTDATED"
51+
message: |
52+
**Found changes in the snapshot tests. Please review.**
53+
<details>
54+
<summary>Diff 📖</summary>
55+
56+
<pre lang="diff"><code>
57+
${{ steps.diff.outputs.body }}
58+
</code></pre>
59+
60+
</details>
61+
- uses: marocchino/sticky-pull-request-comment@v2
62+
if: github.event_name == 'pull_request' && steps.diff.outputs.exitcode == '0'
63+
with:
64+
header: sticky-comment-for-git-diff
65+
hide: true
66+
hide_classify: "OUTDATED"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"scripts": {
1515
"install-plugin": "npm run package && code --install-extension wit-idl.vsix",
1616
"package": "vsce package -o wit-idl.vsix",
17-
"update-snapshot": "vscode-tmgrammar-snap --updateSnapshot --scope 'source.wit' 'tests/grammar/*'",
18-
"test-grammar": "vscode-tmgrammar-test -c --grammar syntaxes/wit.tmLanguage.json 'tests/grammar/*'",
17+
"update-snapshot": "vscode-tmgrammar-snap --updateSnapshot --scope 'source.wit' 'tests/grammar/integration/*'",
18+
"test-grammar": "vscode-tmgrammar-test -c --grammar syntaxes/wit.tmLanguage.json 'tests/grammar/unit/*'",
1919
"test": "npm run test-grammar",
2020
"vscode:prepublish": "npm run compile",
2121
"compile": "tsc -p ./",

tests/grammar/integration/char.wit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package foo:foo
2+
3+
interface chars {
4+
/// A function that accepts a character
5+
take-char: func(x: char)
6+
/// A function that returns a character
7+
return-char: func() -> char
8+
}
9+
10+
world the-world {
11+
import chars
12+
export chars
13+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
>package foo:foo
2+
#^^^^^^^ source.wit meta.package-decl.wit storage.modifier.package-decl.wit
3+
# ^ source.wit meta.package-decl.wit
4+
# ^^^ source.wit meta.package-decl.wit meta.id.package-decl.wit meta.package-identifier.wit entity.name.namespace.package-identifier.wit entity.name.type.id.wit
5+
# ^ source.wit meta.package-decl.wit meta.id.package-decl.wit meta.package-identifier.wit keyword.operator.namespace.package-identifier.wit
6+
# ^^^ source.wit meta.package-decl.wit meta.id.package-decl.wit meta.package-identifier.wit entity.name.type.package-identifier.wit entity.name.type.id.wit
7+
>
8+
>interface chars {
9+
#^^^^^^^^^ source.wit meta.interface-item.wit keyword.declaration.interface.interface-item.wit storage.type.wit
10+
# ^ source.wit meta.interface-item.wit
11+
# ^^^^^ source.wit meta.interface-item.wit entity.name.type.id.interface-item.wit
12+
# ^ source.wit meta.interface-item.wit
13+
# ^ source.wit meta.interface-item.wit punctuation.brackets.curly.begin.wit
14+
> /// A function that accepts a character
15+
#^^^^^ source.wit meta.interface-item.wit comment.line.documentation.wit
16+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.wit meta.interface-item.wit comment.line.documentation.wit
17+
> take-char: func(x: char)
18+
#^^ source.wit meta.interface-item.wit meta.func-item.wit
19+
# ^^^^ source.wit meta.interface-item.wit meta.func-item.wit entity.name.function.id.func-item.wit meta.word.wit
20+
# ^ source.wit meta.interface-item.wit meta.func-item.wit entity.name.function.id.func-item.wit meta.word-separator.wit
21+
# ^^^^ source.wit meta.interface-item.wit meta.func-item.wit entity.name.function.id.func-item.wit meta.word.wit
22+
# ^ source.wit meta.interface-item.wit meta.func-item.wit keyword.operator.key-value.wit
23+
# ^ source.wit meta.interface-item.wit meta.func-item.wit
24+
# ^^^^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit keyword.other.func.func-type.wit
25+
# ^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit punctuation.brackets.round.begin.wit
26+
# ^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit meta.named-type-list.wit variable.parameter.id.named-type.wit
27+
# ^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit meta.named-type-list.wit keyword.operator.key-value.wit
28+
# ^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit meta.named-type-list.wit
29+
# ^^^^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit meta.named-type-list.wit entity.name.type.string.wit
30+
# ^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit punctuation.brackets.round.end.wit
31+
> /// A function that returns a character
32+
#^^^^^ source.wit meta.interface-item.wit comment.line.documentation.wit
33+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.wit meta.interface-item.wit comment.line.documentation.wit
34+
> return-char: func() -> char
35+
#^^ source.wit meta.interface-item.wit meta.func-item.wit
36+
# ^^^^^^ source.wit meta.interface-item.wit meta.func-item.wit entity.name.function.id.func-item.wit meta.word.wit
37+
# ^ source.wit meta.interface-item.wit meta.func-item.wit entity.name.function.id.func-item.wit meta.word-separator.wit
38+
# ^^^^ source.wit meta.interface-item.wit meta.func-item.wit entity.name.function.id.func-item.wit meta.word.wit
39+
# ^ source.wit meta.interface-item.wit meta.func-item.wit keyword.operator.key-value.wit
40+
# ^ source.wit meta.interface-item.wit meta.func-item.wit
41+
# ^^^^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit keyword.other.func.func-type.wit
42+
# ^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit punctuation.brackets.round.begin.wit
43+
# ^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit punctuation.brackets.round.end.wit
44+
# ^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit
45+
# ^^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit meta.result-list.wit keyword.operator.arrow.skinny.wit
46+
# ^^^^^ source.wit meta.interface-item.wit meta.func-item.wit meta.function.wit meta.types.result-list.wit entity.name.type.string.wit
47+
>}
48+
#^ source.wit meta.interface-item.wit punctuation.brackets.curly.end.wit
49+
>
50+
>world the-world {
51+
#^^^^^ source.wit meta.world-item.wit keyword.declaration.world.world-item.wit storage.type.wit
52+
# ^ source.wit meta.world-item.wit
53+
# ^^^^^^^^^ source.wit meta.world-item.wit entity.name.type.id.world-item.wit
54+
# ^ source.wit meta.world-item.wit
55+
# ^ source.wit meta.world-item.wit punctuation.brackets.curly.begin.wit
56+
> import chars
57+
#^^ source.wit meta.world-item.wit meta.import-item.wit
58+
# ^^^^^^ source.wit meta.world-item.wit meta.import-item.wit keyword.control.import.import-item.wit
59+
# ^ source.wit meta.world-item.wit meta.import-item.wit
60+
# ^^^^^ source.wit meta.world-item.wit meta.import-item.wit meta.id.import-item.wit variable.other.id.import-item.wit
61+
> export chars
62+
#^^ source.wit meta.world-item.wit meta.export-item.wit
63+
# ^^^^^^ source.wit meta.world-item.wit meta.export-item.wit keyword.control.export.export-item.wit
64+
# ^ source.wit meta.world-item.wit meta.export-item.wit
65+
# ^^^^^ source.wit meta.world-item.wit meta.export-item.wit meta.id.export-item.wit variable.other.constant.id.export-item.wit
66+
>}
67+
#^ source.wit meta.world-item.wit punctuation.brackets.curly.end.wit
68+
>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// hello 🐱 world
2+
3+
package foo:foo
4+
5+
interface conventions {
6+
kebab-case: func()
7+
8+
record ludicrous-speed {
9+
how-fast-are-you-going: u32,
10+
i-am-going-extremely-slow: u64,
11+
}
12+
13+
foo: func(x: ludicrous-speed)
14+
%function-with-dashes: func()
15+
%function-with-no-weird-characters: func()
16+
17+
apple: func()
18+
apple-pear: func()
19+
apple-pear-grape: func()
20+
a0: func()
21+
22+
// Comment out identifiers that collide when mapped to snake_case, for now; see
23+
// https://github.com/WebAssembly/component-model/issues/118
24+
//APPLE: func()
25+
//APPLE-pear-GRAPE: func()
26+
//apple-PEAR-grape: func()
27+
28+
is-XML: func()
29+
30+
%explicit: func()
31+
%explicit-kebab: func()
32+
33+
// Identifiers with the same name as keywords are quoted.
34+
%bool: func()
35+
}
36+
37+
world the-world {
38+
import conventions
39+
export conventions
40+
}

0 commit comments

Comments
 (0)