Skip to content

Commit

Permalink
update tes runners
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek committed Nov 15, 2023
1 parent 2d5639c commit d904213
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 151 deletions.
110 changes: 55 additions & 55 deletions test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ const child_process = require("child_process");
const fs = require("fs-extra");
const path = require("path");

global.log = function(msg) {
let now = new Date().toLocaleTimeString();
console.log(`[${now}] ${msg}\n`);
global.log = function (msg) {
let now = new Date().toLocaleTimeString();
console.log(`[${now}] ${msg}\n`);
};

// Build the dotnet application in release mode
function build(dir, dotnetVersion) {
global.log("Building ...");
child_process.spawnSync("dotnet", ["build", "-c", "Release", "-f", dotnetVersion], { cwd: dir });
global.log("Building ...");
child_process.spawnSync("dotnet", ["build", "-c", "Release", "-f", dotnetVersion], { cwd: dir });
}

// destructive action that deletes the App_Data folder
function deleteDirectory(dir) {
fs.removeSync(dir);
global.log(`${dir} deleted`);
fs.removeSync(dir);
global.log(`${dir} deleted`);
}

// Copy the migrations recipe.
Expand All @@ -42,57 +42,57 @@ function copyMigrationsRecipeFile(dir) {
}

// Host the dotnet application, does not rebuild
function host(dir, assembly, { appDataLocation='./App_Data', dotnetVersion='net7.0' }={}) {
if (fs.existsSync(path.join(dir, `bin/Release/${dotnetVersion}/`, assembly))) {
global.log("Application already built, skipping build");
} else {
build(dir, dotnetVersion);
}
global.log("Starting application ...");

const ocEnv = {};
ocEnv["ORCHARD_APP_DATA"] = appDataLocation;

let server = child_process.spawn(
"dotnet",
[`bin/Release/${dotnetVersion}/` + assembly],
{ cwd: dir, env: {...process.env, ...ocEnv} }
);

server.stdout.on("data", data => {
global.log(data);
});

server.stderr.on("data", data => {
global.log(`stderr: ${data}`);
});

server.on("close", code => {
global.log(`Server process exited with code ${code}`);
});
return server;
function host(dir, assembly, { appDataLocation = './App_Data', dotnetVersion = 'net8.0' } = {}) {
if (fs.existsSync(path.join(dir, `bin/Release/${dotnetVersion}/`, assembly))) {
global.log("Application already built, skipping build");
} else {
build(dir, dotnetVersion);
}
global.log("Starting application ...");

const ocEnv = {};
ocEnv["ORCHARD_APP_DATA"] = appDataLocation;

let server = child_process.spawn(
"dotnet",
[`bin/Release/${dotnetVersion}/` + assembly],
{ cwd: dir, env: { ...process.env, ...ocEnv } }
);

server.stdout.on("data", data => {
global.log(data);
});

server.stderr.on("data", data => {
global.log(`stderr: ${data}`);
});

server.on("close", code => {
global.log(`Server process exited with code ${code}`);
});
return server;
}

// combines the functions above, useful when triggering tests from CI
function e2e(dir, assembly, { dotnetVersion='net7.0' }={}) {
copyMigrationsRecipeFile(dir);
deleteDirectory(path.join(dir, "App_Data_Tests"));
var server = host(dir, assembly, { appDataLocation: "./App_Data_Tests", dotnetVersion });

let test = child_process.exec("npx cypress run");
test.stdout.on("data", data => {
console.log(data);
});

test.stderr.on("data", data => {
console.log(`stderr: ${data}`);
});

test.on("close", code => {
console.log(`Cypress process exited with code ${code}`);
server.kill("SIGINT");
process.exit(code);
});
function e2e(dir, assembly, { dotnetVersion = 'net8.0' } = {}) {
copyMigrationsRecipeFile(dir);
deleteDirectory(path.join(dir, "App_Data_Tests"));
var server = host(dir, assembly, { appDataLocation: "./App_Data_Tests", dotnetVersion });

let test = child_process.exec("npx cypress run");
test.stdout.on("data", data => {
console.log(data);
});

test.stderr.on("data", data => {
console.log(`stderr: ${data}`);
});

test.on("close", code => {
console.log(`Cypress process exited with code ${code}`);
server.kill("SIGINT");
process.exit(code);
});
}

exports.build = build;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,74 @@ const child_process = require("child_process");
const fs = require("fs-extra");
const path = require("path");

global.log = function(msg) {
let now = new Date().toLocaleTimeString();
console.log(`[${now}] ${msg}\n`);
global.log = function (msg) {
let now = new Date().toLocaleTimeString();
console.log(`[${now}] ${msg}\n`);
};

// Build the dotnet application in release mode
function build(dir) {
global.log("Building ...");
child_process.spawnSync("dotnet", ["build", "-c", "Release"], { cwd: dir });
global.log("Building ...");
child_process.spawnSync("dotnet", ["build", "-c", "Release"], { cwd: dir });
}

// destructive action that deletes the App_Data folder
function deleteDirectory(dir) {
fs.removeSync(dir);
global.log(`${dir} deleted`);
fs.removeSync(dir);
global.log(`${dir} deleted`);
}

// Host the dotnet application, does not rebuild
function host(dir, assembly, { appDataLocation='./App_Data', dotnetVersion='net7.0' }={}) {
if (fs.existsSync(path.join(dir, `bin/Release/${dotnetVersion}/`, assembly))) {
global.log("Application already built, skipping build");
} else {
build(dir);
}
global.log("Starting application ...");

const ocEnv = {};
ocEnv["ORCHARD_APP_DATA"] = appDataLocation;

let server = child_process.spawn(
"dotnet",
[`bin/Release/${dotnetVersion}/` + assembly],
{ cwd: dir, env: {...process.env, ...ocEnv} }
);
function host(dir, assembly, { appDataLocation = './App_Data', dotnetVersion = 'net8.0' } = {}) {
if (fs.existsSync(path.join(dir, `bin/Release/${dotnetVersion}/`, assembly))) {
global.log("Application already built, skipping build");
} else {
build(dir);
}
global.log("Starting application ...");

server.stdout.on("data", data => {
global.log(data);
});
const ocEnv = {};
ocEnv["ORCHARD_APP_DATA"] = appDataLocation;

server.stderr.on("data", data => {
global.log(`stderr: ${data}`);
});
let server = child_process.spawn(
"dotnet",
[`bin/Release/${dotnetVersion}/` + assembly],
{ cwd: dir, env: { ...process.env, ...ocEnv } }
);

server.on("close", code => {
global.log(`Server process exited with code ${code}`);
});
return server;
server.stdout.on("data", data => {
global.log(data);
});

server.stderr.on("data", data => {
global.log(`stderr: ${data}`);
});

server.on("close", code => {
global.log(`Server process exited with code ${code}`);
});
return server;
}

// combines the functions above, useful when triggering tests from CI
function e2e(dir, assembly, { dotnetVersion='net7.0' }={}) {
deleteDirectory(path.join(dir, "App_Data_Tests"));
var server = host(dir, assembly, { appDataLocation: "./App_Data_Tests", dotnetVersion });
function e2e(dir, assembly, { dotnetVersion = 'net8.0' } = {}) {
deleteDirectory(path.join(dir, "App_Data_Tests"));
var server = host(dir, assembly, { appDataLocation: "./App_Data_Tests", dotnetVersion });

let test = child_process.exec("npx cypress run");
test.stdout.on("data", data => {
console.log(data);
});
let test = child_process.exec("npx cypress run");
test.stdout.on("data", data => {
console.log(data);
});

test.stderr.on("data", data => {
console.log(`stderr: ${data}`);
});
test.stderr.on("data", data => {
console.log(`stderr: ${data}`);
});

test.on("close", code => {
console.log(`Cypress process exited with code ${code}`);
server.kill("SIGINT");
process.exit(code);
});
test.on("close", code => {
console.log(`Cypress process exited with code ${code}`);
server.kill("SIGINT");
process.exit(code);
});
}

export { build, deleteDirectory, e2e, host };
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,73 @@ const child_process = require("child_process");
const fs = require("fs-extra");
const path = require("path");

global.log = function(msg) {
let now = new Date().toLocaleTimeString();
console.log(`[${now}] ${msg}\n`);
global.log = function (msg) {
let now = new Date().toLocaleTimeString();
console.log(`[${now}] ${msg}\n`);
};

// Build the dotnet application in release mode
export function build(dir, dotnetVersion) {
global.log("Building ...");
child_process.spawnSync("dotnet", ["build", "-c", "Release", "-f", dotnetVersion], { cwd: dir });
global.log("Building ...");
child_process.spawnSync("dotnet", ["build", "-c", "Release", "-f", dotnetVersion], { cwd: dir });
}

// destructive action that deletes the App_Data folder
export function deleteDirectory(dir) {
fs.removeSync(dir);
global.log(`${dir} deleted`);
fs.removeSync(dir);
global.log(`${dir} deleted`);
}

// Host the dotnet application, does not rebuild
export function host(dir, assembly, { appDataLocation='./App_Data', dotnetVersion='net7.0' }={}) {
if (fs.existsSync(path.join(dir, `bin/Release/${dotnetVersion}/`, assembly))) {
global.log("Application already built, skipping build");
} else {
build(dir, dotnetVersion);
}
global.log("Starting application ...");

const ocEnv = {};
ocEnv["ORCHARD_APP_DATA"] = appDataLocation;

let server = child_process.spawn(
"dotnet",
[`bin/Release/${dotnetVersion}/` + assembly],
{ cwd: dir, env: {...process.env, ...ocEnv} }
);
export function host(dir, assembly, { appDataLocation = './App_Data', dotnetVersion = 'net8.0' } = {}) {
if (fs.existsSync(path.join(dir, `bin/Release/${dotnetVersion}/`, assembly))) {
global.log("Application already built, skipping build");
} else {
build(dir, dotnetVersion);
}
global.log("Starting application ...");

server.stdout.on("data", data => {
global.log(data);
});
const ocEnv = {};
ocEnv["ORCHARD_APP_DATA"] = appDataLocation;

server.stderr.on("data", data => {
global.log(`stderr: ${data}`);
});
let server = child_process.spawn(
"dotnet",
[`bin/Release/${dotnetVersion}/` + assembly],
{ cwd: dir, env: { ...process.env, ...ocEnv } }
);

server.on("close", code => {
global.log(`Server process exited with code ${code}`);
});
return server;
server.stdout.on("data", data => {
global.log(data);
});

server.stderr.on("data", data => {
global.log(`stderr: ${data}`);
});

server.on("close", code => {
global.log(`Server process exited with code ${code}`);
});
return server;
}

// combines the functions above, useful when triggering tests from CI
export function e2e(dir, assembly, { dotnetVersion='net7.0' }={}) {
deleteDirectory(path.join(dir, "App_Data_Tests"));
var server = host(dir, assembly, { appDataLocation: "./App_Data_Tests", dotnetVersion });
export function e2e(dir, assembly, { dotnetVersion = 'net8.0' } = {}) {
deleteDirectory(path.join(dir, "App_Data_Tests"));
var server = host(dir, assembly, { appDataLocation: "./App_Data_Tests", dotnetVersion });

let test = child_process.exec("npx cypress run");
test.stdout.on("data", data => {
console.log(data);
});
let test = child_process.exec("npx cypress run");
test.stdout.on("data", data => {
console.log(data);
});

test.stderr.on("data", data => {
console.log(`stderr: ${data}`);
});
test.stderr.on("data", data => {
console.log(`stderr: ${data}`);
});

test.on("close", code => {
console.log(`Cypress process exited with code ${code}`);
server.kill("SIGINT");
process.exit(code);
});
test.on("close", code => {
console.log(`Cypress process exited with code ${code}`);
server.kill("SIGINT");
process.exit(code);
});
}

0 comments on commit d904213

Please sign in to comment.