Skip to content

Commit

Permalink
Fix fs paths and tree-sitter test execution on windows
Browse files Browse the repository at this point in the history
Addresses #12
  • Loading branch information
bollian committed Feb 24, 2024
1 parent c1f6ae5 commit 96878a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 39 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"repository": "https://github.com/bollian/tree-sitter-openscad",
"scripts": {
"build": "tree-sitter generate && node-gyp build",
"test": "node --test",
"test": "tree-sitter test && node --test",
"parse": "tree-sitter parse",
"test-windows": "tree-sitter test"
},
Expand Down
65 changes: 27 additions & 38 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,42 @@
const fs = require('node:fs');
const path = require('node:path');
const { spawn } = require('node:child_process');
const { describe, test } = require('node:test');
const Parser = require('tree-sitter');
const OpenScad = require('.');
const assert = require('node:assert').strict;

const openscad_tests_root = 'examples/openscad/tests/data/scad';
const openscad_tests_root = path.join('examples', 'openscad', 'tests', 'data', 'scad');
const expected_failed_parses = [
'2D/features/text-search-test.scad',
'3D/features/polyhedron-nonplanar-tests.scad',
'customizer/allexpressionscomment.scad',
'functions/assert-expression-fail1-test.scad',
'functions/assert-expression-fail2-test.scad',
'functions/assert-expression-tests.scad',
'functions/echo-expression-tests.scad',
'functions/expression-precedence-tests.scad',
'functions/let-tests.scad',
'functions/trig-tests.scad',
'issues/issue1851-each-fail-on-scalar.scad',
'misc/allexpressions.scad',
'misc/assert-fail5-test.scad',
'misc/assert-tests.scad',
'misc/let-module-tests.scad',
'misc/nbsp-latin1-test.scad',
'misc/nbsp-utf8-test.scad',
'misc/no-break-space-test.scad',
'misc/parser-tests.scad',
'misc/scope-assignment-tests.scad',
'misc/tail-recursion-tests.scad',
'misc/variable-overwrite.scad',
path.join('2D', 'features', 'text-search-test.scad'),
path.join('3D', 'features', 'polyhedron-nonplanar-tests.scad'),
path.join('customizer', 'allexpressionscomment.scad'),
path.join('functions', 'assert-expression-fail1-test.scad'),
path.join('functions', 'assert-expression-fail2-test.scad'),
path.join('functions', 'assert-expression-tests.scad'),
path.join('functions', 'echo-expression-tests.scad'),
path.join('functions', 'expression-precedence-tests.scad'),
path.join('functions', 'let-tests.scad'),
path.join('functions', 'trig-tests.scad'),
path.join('issues', 'issue1851-each-fail-on-scalar.scad'),
path.join('misc', 'allexpressions.scad'),
path.join('misc', 'assert-fail5-test.scad'),
path.join('misc', 'assert-tests.scad'),
path.join('misc', 'let-module-tests.scad'),
path.join('misc', 'nbsp-latin1-test.scad'),
path.join('misc', 'nbsp-utf8-test.scad'),
path.join('misc', 'no-break-space-test.scad'),
path.join('misc', 'parser-tests.scad'),
path.join('misc', 'scope-assignment-tests.scad'),
path.join('misc', 'tail-recursion-tests.scad'),
path.join('misc', 'variable-overwrite.scad'),
];
const ignored_examples = [
'issues/issue1890-comment.scad',
'issues/issue1890-include.scad',
'issues/issue1890-string.scad',
'issues/issue1890-use.scad',
path.join('issues', 'issue1890-comment.scad'),
path.join('issues', 'issue1890-include.scad'),
path.join('issues', 'issue1890-string.scad'),
path.join('issues', 'issue1890-use.scad'),
];

test('tree-sitter test', async (_t) => {
const ts_test = spawn('npx', ['tree-sitter', 'test'], {
windowsHide: true,
});
await new Promise(resolve => ts_test.on('exit', code => {
assert.strictEqual(code, 0);
resolve();
}));
});

describe('Upstream OpenSCAD test samples', () => {
const parser = new Parser();
parser.setLanguage(OpenScad);
Expand Down

0 comments on commit 96878a2

Please sign in to comment.