Socket
Socket
Sign inDemoInstall

vscode-tmgrammar-test

Package Overview
Dependencies
6
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.11 to 0.1.1

CONTRIBUTING.md

15

package.json
{
"name": "vscode-tmgrammar-test",
"version": "0.0.11",
"description": "Test helper for VSCode textmate grammars",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts",
"version": "0.1.1",
"description": "Test runner for VSCode textmate grammars",
"homepage": "https://github.com/PanAeon/vscode-tmgrammar-test",

@@ -23,4 +21,4 @@ "repository": {

"bin": {
"vscode-tmgrammar-test": "./dist/src/unit.js",
"vscode-tmgrammar-snap": "./dist/src/snapshot.js"
"vscode-tmgrammar-test": "./dist/unit.js",
"vscode-tmgrammar-snap": "./dist/snapshot.js"
},

@@ -45,3 +43,2 @@ "keywords": [

"chai": "^4.2.0",
"istanbul": "^0.4.5",
"mocha": "^6.2.3",

@@ -56,8 +53,8 @@ "nyc": "^15.0.1",

"chalk": "^2.4.2",
"commander": "^2.20.3",
"commander": "^9.2.0",
"diff": "^4.0.2",
"glob": "^7.1.6",
"vscode-oniguruma": "^1.5.1",
"vscode-textmate": "^5.4.0"
"vscode-textmate": "^7.0.1"
}
}

117

README.md

@@ -7,9 +7,6 @@ ![Node.js CI](https://img.shields.io/github/workflow/status/PanAeon/vscode-tmgrammar-test/Node.js%20CI?style=for-the-badge) ![NPM Version](https://img.shields.io/npm/v/vscode-tmgrammar-test?style=for-the-badge)

* Unit tests:
![Showcase unit](images/showcase.gif?raw=true "unit test in action")
Demo:
* Snapshot tests:
[![asciicast](https://asciinema.org/a/QoGS5fPsxDOHl1T43zzmFxJAU.svg)](https://asciinema.org/a/QoGS5fPsxDOHl1T43zzmFxJAU)
![Showcase snap](images/Snapshots.png "snapshots test in action")
Inspired by [Sublime Text syntax tests](https://www.sublimetext.com/docs/3/syntax.html#testing)

@@ -23,3 +20,3 @@

```bash
npm i --save vscode-tmgrammar-test
npm i --save-dev vscode-tmgrammar-test
```

@@ -40,3 +37,3 @@

// line which start with a <comment token> but don't have valid assertions are ignored
// line can start with a <comment token> and not have a valid assertion

@@ -51,13 +48,2 @@ class Stack[A] {

// ^ punctuation.section.block.begin.scala
private var elements: List[A] = Nil
def push(x: A) { elements = x :: elements }
def peek: A = elements.head
def pop(): A = {
val currentTop = peek
elements = elements.tail
currentTop
}
// <~~- punctuation.section.block.end.scala
}
```

@@ -97,3 +83,3 @@

Any lines which start with a `<comment token>` will be ignored by the textmate grammar.
Lines which start with a `<comment token>` and assertion symbol are ignored by the textmate grammar.

@@ -104,2 +90,8 @@

To run a unit test:
```bash
vscode-tmgrammar-test 'tests/unit/**/*.test.scala'
```
### Snapshot tests

@@ -115,3 +107,3 @@ Snapshot tests are like `functional tests` but you don't have to write outputs explicitly.

```bash
vscode-tmgrammar-snap .... --updateSnapshot
vscode-tmgrammar-snap --updateSnapshot ....
```

@@ -123,44 +115,79 @@ this will overwrite the existing `.snap` files with a new ones.

To run snapshot test:
```bash
vscode-tmgrammar-snap 'tests/snap/**/*.scala'
```
### Language configuration via package.json
The configuration follows the format of vscode:
```json
{
"contributes": {
"languages": [
{
"id": "scala",
"extensions": [
".scala",
".sbt",
".sc"
]
}
],
"grammars": [
{
"language": "scala",
"scopeName": "source.scala",
"path": "./syntaxes/Scala.tmLanguage.json"
}
]
}
}
```
The idea is that for the average language extension all necessary information for tests are already included in the `package.json`.
It is optional, though. If the configuration is missing it is necessary to specify grammars and scopeName of testcases via command line options.
Right now only regular grammars and *Injection Grammars* via `injectTo` directive are supported.
### Command Line Options
* Unit tests:
Unit tests:
```
Usage: vscode-tmgrammar-test [options]
Usage: vscode-tmgrammar-test [options] <testcases...>
Run Textmate grammar test cases using vscode-textmate
Arguments:
testcases A glob pattern(s) which specifies testcases to run, e.g. "./tests/**/test*.dhall". Quotes are important!
Options:
-V, --version output the version number
-s, --scope <scope> Language scope, e.g. source.dhall
-g, --grammar <grammar> Path to a grammar file, either .json or .xml. This option can be specified multiple times if multiple grammar needed. (default: [])
-t, --testcases <glob> A glob pattern which specifies testcases to run, e.g. "./tests/**/test*.dhall". Quotes are important!
-c, --compact Display output in the compact format, which is easier to use with VSCode problem matchers
-h, --help output usage information
-g, --grammar <grammar> Path to a grammar file. Multiple options supported. 'scopeName' is taken from the grammar (default: [])
--config <configuration.json> Path to the language configuration, package.json by default
-c, --compact Display output in the compact format, which is easier to use with VSCode problem matchers
-V, --version output the version number
-h, --help display help for command
```
* Snapshot tests:
Snapshot tests:
```
Usage: vscode-tmgrammar-snap [options]
Usage: vscode-tmgrammar-snap [options] <testcases...>
Run VSCode textmate grammar snapshot tests
Arguments:
testcases A glob pattern(s) which specifies testcases to run, e.g. "./tests/**/test*.dhall". Quotes are important!
Options:
-V, --version output the version number
-s, --scope <scope> Language scope, e.g. source.dhall
-g, --grammar <grammar> Path to a grammar file, either .json or .xml. This option can be specified multiple times if multiple grammar needed. (default: [])
-t, --testcases <glob> A glob pattern which specifies testcases to run, e.g. "./tests/**/test*.dhall". Quotes are important!
-u, --updateSnapshot overwrite all snap files with new changes
--printNotModified include not modified scopes in the output
--expandDiff produce each diff on two lines prefixed with "++" and "--"
-h, --help output usage information
-u, --updateSnapshot overwrite all snap files with new changes
--config <configuration.json> Path to the language configuration, package.json by default
--printNotModified include not modified scopes in the output (default: false)
--expandDiff produce each diff on two lines prefixed with "++" and "--" (default: false)
-g, --grammar <grammar> Path to a grammar file. Multiple options supported. 'scopeName' is taken from the grammar (default: [])
-s, --scope <scope> Explicitly specify scope of testcases, e.g. source.dhall
-V, --version output the version number
-h, --help display help for command
```
Example:
```bash
> vscode-tmgrammar-test -s source.dhall -g testcase/dhall.tmLanguage.json -t "**/*.dhall"
```
### Setup VSCode unit test task

@@ -174,3 +201,3 @@

"type": "shell",
"command": "vscode-tmgrammar-test -c -s source.dhall -g testcase/dhall.tmLanguage.json -t \"**/*.dhall\"",
"command": "vscode-tmgrammar-test -c -g testcase/dhall.tmLanguage.json \"**/*.dhall\"",
"group": "test",

@@ -177,0 +204,0 @@ "presentation": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc