Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for windows issues #2

Merged
merged 2 commits into from Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -125,7 +125,7 @@ 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
-t, --testcases <glob> A glob pattern which specifies testcases to run, e.g. './tests/**/test*.dhall'. Quotes are important!
-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
```
Expand All @@ -140,7 +140,7 @@ 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
-t, --testcases <glob> A glob pattern which specifies testcases to run, e.g. './tests/**/test*.dhall'. Quotes are important!
-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 "--"
Expand All @@ -150,7 +150,7 @@ Options:
Example:

```bash
> vscode-tmgrammar-test -s source.dhall -g testcase/dhall.tmLanguage.json -t '**/*.dhall'
> vscode-tmgrammar-test -s source.dhall -g testcase/dhall.tmLanguage.json -t "**/*.dhall"
```

### Setup VSCode unit test task
Expand All @@ -161,7 +161,7 @@ You can setup a vscode unit test task for convenience:
{
"label": "Run tests",
"type": "shell",
"command": "vscode-tmgrammar-test -c -s source.dhall -g testcase/dhall.tmLanguage.json -t '**/*.dhall'",
"command": "vscode-tmgrammar-test -c -s source.dhall -g testcase/dhall.tmLanguage.json -t \"**/*.dhall\"",
"group": "test",
"presentation": {
"reveal": "always",
Expand Down
2 changes: 1 addition & 1 deletion src/snapshot.ts
Expand Up @@ -26,7 +26,7 @@ program
.description("Run VSCode textmate grammar snapshot tests")
.option('-s, --scope <scope>', 'Language scope, e.g. source.dhall')
.option('-g, --grammar <grammar>', 'Path to a grammar file, either .json or .xml')
.option('-t, --testcases <glob>', 'A glob pattern which specifies testcases to run, e.g. \'./tests/**/test*.dhall\'. Quotes are important!')
.option('-t, --testcases <glob>', 'A glob pattern which specifies testcases to run, e.g. \"./tests/**/test*.dhall\". Quotes are important!')
.option("-u, --updateSnapshot", 'overwrite all snap files with new changes')
.option("--printNotModified", 'include not modified scopes in the output', false)
.option("--expandDiff", 'produce each diff on two lines prefixed with "++" and "--"', false)
Expand Down
3 changes: 2 additions & 1 deletion src/snapshot/index.ts
Expand Up @@ -2,6 +2,7 @@

import * as tm from 'vscode-textmate';
import { AnnotatedLine } from './model';
import { EOL } from 'os';



Expand All @@ -11,7 +12,7 @@ export async function getVSCodeTokens(registry: tm.Registry, scope: string, sour

let ruleStack: tm.StackElement = <any>null;

return source.split("\n").map((line: string, n: number) => {
return source.split(EOL).map((line: string, n: number) => {
var {tokens, ruleStack:ruleStack1} = grammar.tokenizeLine(line, ruleStack);
ruleStack = ruleStack1;

Expand Down
3 changes: 2 additions & 1 deletion src/snapshot/parsing.ts
@@ -1,9 +1,10 @@

import {AnnotatedLine, IToken} from "./model"
import {EOL} from 'os'

export function parseSnap(s:string): AnnotatedLine[] {
let result: AnnotatedLine[] = []
let ls = s.split("\n")
let ls = s.split(EOL)
let i = 0
while(i < ls.length) {
let l = ls[i];
Expand Down
2 changes: 1 addition & 1 deletion src/unit.ts
Expand Up @@ -20,7 +20,7 @@ program
.description("Run Textmate grammar test cases using vscode-textmate")
.option('-s, --scope <scope>', 'Language scope, e.g. source.dhall')
.option('-g, --grammar <grammar>', 'Path to a grammar file, either .json or .xml')
.option('-t, --testcases <glob>', 'A glob pattern which specifies testcases to run, e.g. \'./tests/**/test*.dhall\'. Quotes are important!')
.option('-t, --testcases <glob>', 'A glob pattern which specifies testcases to run, e.g. \"./tests/**/test*.dhall\". Quotes are important!')
.option('-c, --compact', 'Display output in the compact format, which is easier to use with VSCode problem matchers')
.parse(process.argv);

Expand Down
3 changes: 2 additions & 1 deletion src/unit/parsing.ts
@@ -1,5 +1,6 @@

import { ScopeAssertion, TestCaseMetadata, LineAssertion, GrammarTestCase } from './model';
import { EOL } from 'os';

const leftArrowAssertRegex = /^\s*<([~]*)([-]+)((?:\s*\w[-\w.]*)*)(?:\s*-)?((?:\s*\w[-\w.]*)*)\s*$/
const upArrowAssertRegex = /^\s*(\^+)((?:\s*\w[-\w.]*)*)(?:\s*-)?((?:\s*\w[-\w.]*)*)\s*$/
Expand Down Expand Up @@ -78,7 +79,7 @@ export function parseHeader(as: string[]): TestCaseMetadata {

export function parseGrammarTestCase(str: string): GrammarTestCase {
let headerLength = 1;
let lines = str.split("\n")
let lines = str.split(EOL);
let metadata = parseHeader(lines)
let { commentToken } = metadata
let rest = lines.slice(headerLength)
Expand Down