Skip to content

Commit

Permalink
coerce other version before comparing
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Jan 18, 2022
1 parent 2c1a793 commit a591c84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export class FunctionalTestRunner {

if (!this.esVersion.eql(esInfo.version.number)) {
throw new Error(
`ES reports a version number "${esInfo.version.number}" which doesn't match supplied es version "${this.esVersion}"`
`ES reports a version number "${
esInfo.version.number
}" which doesn't match supplied es version "${this.esVersion.toString()}"`
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export class EsVersion {
this.parsed = parsed;
}

toString() {
return this.parsed.version;
}

/**
* Determine if the ES version matches a semver range, like >=7 or ^8.1.0
*/
Expand All @@ -45,6 +49,7 @@ export class EsVersion {
* Determine if the ES version matches a specific version, ignores things like -SNAPSHOT
*/
eql(version: string) {
return semver.compareLoose(this.parsed, version) === 0;
const other = semver.coerce(version);
return other && semver.compareLoose(this.parsed, other) === 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function filterSuites({ log, mocha, include, exclude, esVersion }: Option
suite.suites.reduce((acc, s) => acc.concat(collectTests(s)), suite.tests);

// traverse the test graph and exclude any tests which don't meet their esVersionRequirement
log.info('Only running suites which are compatible with ES version', esVersion);
log.info('Only running suites which are compatible with ES version', esVersion.toString());
(function recurse(parentSuite: SuiteInternal) {
const children = parentSuite.suites;
parentSuite.suites = [];
Expand Down

0 comments on commit a591c84

Please sign in to comment.