From d904213ce1e6a89346ee0997e378aa6dc38c55f7 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Wed, 15 Nov 2023 10:22:50 -0800 Subject: [PATCH] update tes runners --- .../cypress-commands/dist/test-runner.js | 110 +++++++++--------- .../cypress-commands/dist/test-runner.mjs | 96 +++++++-------- .../cypress-commands/src/test-runner.js | 96 +++++++-------- 3 files changed, 151 insertions(+), 151 deletions(-) diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.js b/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.js index 2ceacead2d0..3900795a6e2 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.js +++ b/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.js @@ -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. @@ -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; diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.mjs b/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.mjs index 0854db29c02..48b9bb7c717 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.mjs +++ b/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.mjs @@ -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 }; diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/src/test-runner.js b/test/OrchardCore.Tests.Functional/cypress-commands/src/test-runner.js index 97c7e28463e..13cdc13b65a 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/src/test-runner.js +++ b/test/OrchardCore.Tests.Functional/cypress-commands/src/test-runner.js @@ -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); + }); }