Support specifying minimum Node version a test requires (#5765)
This commit is contained in:
parent
bf9baa182b
commit
8abe061fab
@ -188,6 +188,15 @@ If you need to check for an error that is thrown you can add to the `options.jso
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If the test requires a minimum Node version, you can add `minNodeVersion` (must be in semver format).
|
||||||
|
|
||||||
|
```js
|
||||||
|
// options.json example
|
||||||
|
{
|
||||||
|
"minNodeVersion": "5.0.0"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### Bootstrapping expected output
|
#### Bootstrapping expected output
|
||||||
|
|
||||||
For both `babel-plugin-x` and `babylon`, you can easily generate an `expected.js`/`expected.json` automatically by just providing `actual.js` and running the tests as you usually would.
|
For both `babel-plugin-x` and `babylon`, you can easily generate an `expected.js`/`expected.json` automatically by just providing `actual.js` and running the tests as you usually would.
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^4.2.0",
|
"lodash": "^4.2.0",
|
||||||
"try-resolve": "^1.0.0"
|
"try-resolve": "^1.0.0",
|
||||||
|
"semver": "^5.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,12 @@ import trimEnd from "lodash/trimEnd";
|
|||||||
import resolve from "try-resolve";
|
import resolve from "try-resolve";
|
||||||
import clone from "lodash/clone";
|
import clone from "lodash/clone";
|
||||||
import merge from "lodash/merge";
|
import merge from "lodash/merge";
|
||||||
|
import semver from "semver";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
|
const nodeVersion = semver.clean(process.version.slice(1));
|
||||||
|
|
||||||
function humanize(val, noext) {
|
function humanize(val, noext) {
|
||||||
if (noext) val = path.basename(val, path.extname(val));
|
if (noext) val = path.basename(val, path.extname(val));
|
||||||
return val.replace(/-/g, " ");
|
return val.replace(/-/g, " ");
|
||||||
@ -125,6 +128,22 @@ export default function get(entryLoc): Array<Suite> {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If there's node requirement, check it before pushing task
|
||||||
|
if (taskOpts.minNodeVersion) {
|
||||||
|
const minimumVersion = semver.clean(taskOpts.minNodeVersion);
|
||||||
|
|
||||||
|
if (minimumVersion == null) {
|
||||||
|
throw new Error(`'minNodeVersion' has invalid semver format: ${taskOpts.minNodeVersion}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (semver.lt(nodeVersion, minimumVersion)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete to avoid option validation error
|
||||||
|
delete taskOpts.minNodeVersion;
|
||||||
|
}
|
||||||
|
|
||||||
// traceur checks
|
// traceur checks
|
||||||
|
|
||||||
if (test.exec.code.indexOf("// Async.") >= 0) {
|
if (test.exec.code.indexOf("// Async.") >= 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user