Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit ede1290

Browse files
Make version number tests more tolerant of invalid version numbers
1 parent b9170dc commit ede1290

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/compiler.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ var Semver = require('semver');
2929
var compilerVersionExpr = /^Version:\sv(.*)$/m;
3030
require('mocha');
3131

32+
var assertError = new should.Assertion('compiler version');
33+
assertError.params = {
34+
operator: 'should be a semver parseabe',
35+
};
36+
3237
describe('compiler.jar', function() {
3338
this.slow(1000);
3439

@@ -37,6 +42,7 @@ describe('compiler.jar', function() {
3742
compiler.run(function(exitCode, stdout, stderr) {
3843
var versionInfo = (stdout || '').match(compilerVersionExpr);
3944
should(versionInfo).not.be.eql(null);
45+
versionInfo = versionInfo || [];
4046
versionInfo.length.should.be.eql(2);
4147
versionInfo[1].indexOf('SNAPSHOT').should.be.below(0);
4248
done();
@@ -50,10 +56,15 @@ describe('compiler.jar', function() {
5056
compiler.run(function(exitCode, stdout, stderr) {
5157
var versionInfo = (stdout || '').match(compilerVersionExpr);
5258
should(versionInfo).not.be.eql(null);
59+
versionInfo = versionInfo || [];
5360
versionInfo.length.should.be.eql(2);
5461

55-
var compilerVersion = new Semver(versionInfo[1] + '.0.0');
56-
compilerVersion.major.should.be.aboveOrEqual(packageVer.major);
62+
try {
63+
var compilerVersion = new Semver(versionInfo[1] + '.0.0');
64+
compilerVersion.major.should.be.aboveOrEqual(packageVer.major);
65+
} catch (e) {
66+
assertError.fail();
67+
}
5768
done();
5869
});
5970
});

0 commit comments

Comments
 (0)