Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable testing on win32 platform #327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bin/regenerator.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\regenerator" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\regenerator" %*
)
38 changes: 23 additions & 15 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ var spawn = require("child_process").spawn;
var regenerator = require("../main");
var mochaDir = path.dirname(require.resolve("mocha"));

var mochaCmd = "mocha";
var regeneratorCmd = "./bin/regenerator";

if (require("os").platform() === "win32") {
mochaCmd = "mocha.cmd";
regeneratorCmd = "bin\\regenerator.cmd";
}

function convert(es6File, es5File, callback) {
fs.readFile(es6File, "utf-8", function(err, es6) {
if (err) {
Expand Down Expand Up @@ -84,7 +92,7 @@ function makeMochaCopyFunction(fileName) {
}

if (semver.gte(process.version, "0.11.2")) {
enqueue("mocha", [
enqueue(mochaCmd, [
"--harmony",
"--reporter", "spec",
"--require", "./test/runtime.js",
Expand All @@ -93,7 +101,7 @@ if (semver.gte(process.version, "0.11.2")) {
}

if (semver.gte(process.version, "4.0.0")) {
enqueue("mocha", [
enqueue(mochaCmd, [
"--harmony",
"--reporter", "spec",
"--require", "./test/runtime.js",
Expand Down Expand Up @@ -177,7 +185,7 @@ if (!semver.eq(process.version, "0.11.7")) {
}
}

enqueue("mocha", [
enqueue(mochaCmd, [
"--reporter", "spec",
"--require", "./test/runtime.js",
"./test/tests.es5.js",
Expand All @@ -190,21 +198,21 @@ enqueue("mocha", [

// Run command-line tool with available options to make sure it works.

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"./test/async.es5.js"
], true);

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"--include-runtime",
"./test/async.es5.js"
], true);

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"--disable-async",
"./test/async.es5.js"
], true);

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"--include-runtime",
"--disable-async",
"./test/async.es5.js"
Expand All @@ -213,21 +221,21 @@ enqueue("./bin/regenerator", [
// Make sure we run the command-line tool on a file that does not need any
// transformation, too.

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"./test/nothing-to-transform.js"
], true);

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"--include-runtime",
"./test/nothing-to-transform.js"
], true);

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"--disable-async",
"./test/nothing-to-transform.js"
], true);

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"--include-runtime",
"--disable-async",
"./test/nothing-to-transform.js"
Expand All @@ -237,21 +245,21 @@ enqueue("./bin/regenerator", [
//
// You passed `path.replaceWith()` a falsy node, use `path.remove()` instead

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"./test/replaceWith-falsy.js"
], true);

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"--include-runtime",
"./test/replaceWith-falsy.js"
], true);

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"--disable-async",
"./test/replaceWith-falsy.js"
], true);

enqueue("./bin/regenerator", [
enqueue(regeneratorCmd, [
"--include-runtime",
"--disable-async",
"./test/replaceWith-falsy.js"
Expand Down