Skip to content
Snippets Groups Projects
Unverified Commit 005c221e authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

[Cypress runner] Get version (#17015) (#17047)

* Extract `readFile` into runner utils

* Extract `getVersion` function into a separate file
parent a209702b
No related branches found
No related tags found
No related merge requests found
const { printBold, printCyan, readFile } = require("./cypress-runner-utils.js");
const getVersion = async () => {
try {
const version = await readFile(
__dirname + "/../../../resources/version.properties",
);
printBold("Running e2e test runner with this build:");
printCyan(version);
printBold(
"If that version seems too old, please run `./bin/build version uberjar`.",
);
} catch (e) {
printBold(
"No version file found. Please run `./bin/build version uberjar`.",
);
process.exit(1);
}
};
module.exports = getVersion;
const fs = require("fs");
const chalk = require("chalk");
function printBold(message) {
......@@ -12,4 +13,15 @@ function printCyan(message) {
console.log(chalk.cyan(message));
}
module.exports = { printBold, printYellow, printCyan };
const readFile = fileName => {
return new Promise(function(resolve, reject) {
fs.readFile(fileName, "utf8", (err, data) => {
if (err) {
reject(err);
}
resolve(data);
});
});
};
module.exports = { printBold, printYellow, printCyan, readFile };
import { spawn } from "child_process";
import fs from "fs";
const { printBold, printYellow, printCyan } = require("./cypress-runner-utils");
const getVersion = require("./cypress-runner-get-version");
const { printBold, printYellow } = require("./cypress-runner-utils");
// Use require for BackendResource to run it after the mock afterAll has been set
const BackendResource = require("./backend.js").BackendResource;
......@@ -20,34 +21,9 @@ const specs = userArgs[userArgs.indexOf("--spec") + 1];
const isSingleSpec = !specs || !specs.match(/,/);
const testFiles = isSingleSpec ? specs : specs.split(",");
function readFile(fileName) {
return new Promise(function(resolve, reject) {
fs.readFile(fileName, "utf8", (err, data) => {
if (err) {
reject(err);
}
resolve(data);
});
});
}
const init = async () => {
try {
const version = await readFile(
__dirname + "/../../../resources/version.properties",
);
printBold("Running e2e test runner with this build:");
printCyan(version);
printBold(
"If that version seems too old, please run `./bin/build version uberjar`.\n",
);
} catch (e) {
printBold(
"No version file found. Please run `./bin/build version uberjar`.",
);
process.exit(1);
}
printBold("Metabase version info");
await getVersion();
printBold("Starting backend");
await BackendResource.start(server);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment