Skip to content

Commit 13d67ae

Browse files
committed
- fail tests if no phino util found
1 parent 2746370 commit 13d67ae

File tree

1 file changed

+12
-48
lines changed

1 file changed

+12
-48
lines changed

test/commands/test_normalize.js

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,19 @@ const path = require('path');
99
const {execSync} = require('child_process');
1010
const {runSync, parserVersion, homeTag, weAreOnline} = require('../helpers');
1111

12-
/**
13-
* Check whether phino is installed on this machine.
14-
* @return {boolean} - true if phino is available
15-
*/
16-
function phinoInstalled() {
17-
try {
18-
execSync('phino --version', {stdio: 'pipe'});
19-
return true;
20-
} catch (e) {
21-
return false;
22-
}
23-
}
24-
2512
describe('normalize', () => {
2613
before(weAreOnline);
27-
it('normalizes EO files and saves originals in before-normalize/', function(done) {
28-
if (!phinoInstalled()) {
29-
this.skip();
14+
before(() => {
15+
try {
16+
execSync('phino --version', {stdio: 'pipe'});
17+
} catch (e) {
18+
throw new Error(
19+
'phino is required to run normalize tests, see https://github.com/objectionary/phino',
20+
{cause: e}
21+
);
3022
}
23+
});
24+
it('normalizes EO files and saves originals in before-normalize/', done => {
3125
const home = path.resolve('temp/test-normalize/simple');
3226
const source = path.resolve(home, 'src');
3327
const target = path.resolve(home, 'target');
@@ -54,10 +48,7 @@ describe('normalize', () => {
5448
);
5549
done();
5650
});
57-
it('normalized output matches expected content', function(done) {
58-
if (!phinoInstalled()) {
59-
this.skip();
60-
}
51+
it('normalized output matches expected content', done => {
6152
const home = path.resolve('temp/test-normalize/content');
6253
const source = path.resolve(home, 'src');
6354
const target = path.resolve(home, 'target');
@@ -81,10 +72,7 @@ describe('normalize', () => {
8172
);
8273
done();
8374
});
84-
it('backup matches original input and all pipeline files are produced', function(done) {
85-
if (!phinoInstalled()) {
86-
this.skip();
87-
}
75+
it('backup matches original input and all pipeline files are produced', done => {
8876
const home = path.resolve('temp/test-normalize/pipeline');
8977
const source = path.resolve(home, 'src');
9078
const target = path.resolve(home, 'target');
@@ -126,28 +114,4 @@ describe('normalize', () => {
126114
assert(normalized.length > 0, 'Normalized .eo file must not be empty');
127115
done();
128116
});
129-
it('fails when phino is not installed', function(done) {
130-
if (phinoInstalled()) {
131-
this.skip();
132-
}
133-
const home = path.resolve('temp/test-normalize/no-phino');
134-
const source = path.resolve(home, 'src');
135-
const target = path.resolve(home, 'target');
136-
fs.rmSync(home, {recursive: true, force: true});
137-
fs.mkdirSync(source, {recursive: true});
138-
fs.mkdirSync(target, {recursive: true});
139-
fs.writeFileSync(path.resolve(source, 'simple.eo'), '# sample\n[] > simple\n');
140-
assert.throws(
141-
() => runSync([
142-
'normalize',
143-
'--verbose',
144-
`--parser=${parserVersion}`,
145-
`--home-tag=${homeTag}`,
146-
'-s', source,
147-
'-t', target,
148-
]),
149-
'normalize should fail when phino is not installed'
150-
);
151-
done();
152-
});
153117
});

0 commit comments

Comments
 (0)