Skip to content

Commit

Permalink
Merge pull request #2 from fachammer/bugfix/platform-conforming-line-…
Browse files Browse the repository at this point in the history
…endings

Fix for windows issues
  • Loading branch information
PanAeon committed Sep 9, 2019
2 parents 84f1a66 + 03d5ccb commit a10f48a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a10f48a

Please sign in to comment.