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

fix: ignore stderr if qmate is not executed from a valid git repo #337

Merged
merged 8 commits into from
Jan 30, 2025
Merged
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"test:core:dataExchange:standard": "npx wdio ./test/core/dataExchange/config.js",
"test:core:dataExchange:parallel": "npx wdio ./test/core/dataExchange/config.parallel.js",
"test:core:dataExchange:parallelGroup": "npx wdio ./test/core/dataExchange/config.parallel.group.js",
"test:core:dataExchange": "npm run test:core:dataExchange:export && npm run test:core:dataExchange:import && npm run test:core:dataExchange:standard && npm run test:core:dataExchange:parallel && npm run test:core:dataExchange:parallelGroup",
"test:core:dataExchange": "npm run test:core:dataExchange:export && npm run test:core:dataExchange:import && npm run test:core:dataExchange:parallel && npm run test:core:dataExchange:parallelGroup",
"test:core:functional:chaining": "npx wdio ./test/core/functional/chaining/test.conf.js",
"test:core:functional:locator": "npx wdio ./test/core/functional/locators/test.locator.conf.js",
"test:core:functional:nativeBrowser": "npx wdio ./test/core/functional/nativeBrowser/test.conf.js",
Expand Down
23 changes: 14 additions & 9 deletions src/scripts/stats/getConfigurationInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,32 @@ import path from "path";

function azureGetGitRoot(): string {
if (process.env.BUILD_REPOSITORY_LOCALPATH) {
return process.env.BUILD_REPOSITORY_LOCALPATH
return process.env.BUILD_REPOSITORY_LOCALPATH;
} else {
throw Error();
}
}
}

function getGitRoot(): string {
function getGitRoot(configPath: string): string {
try {
return execSync("git rev-parse --show-toplevel").toString().trim();
return execSync("git rev-parse --show-toplevel", {
cwd: configPath, // Run the command in the configPath directory to support absolute path execution
stdio: ["pipe", "pipe", "ignore"] // Ignore stderr
})
.toString()
.trim();
} catch (error) {
// Intentionally left blank
}

try {
return azureGetGitRoot()
return azureGetGitRoot();
} catch (error) {
// Intentionally left blank
}

throw Error();
}
}

export function getConfigurationHash(): string {
const FALLBACK_NO_CONFIG_HASH = "FALLBACK_NO_CONFIG_HASH";
Expand All @@ -34,7 +39,7 @@ export function getConfigurationHash(): string {
if (process.env.CONFIG_PATH) {
const configPath = process.env.CONFIG_PATH;
try {
const gitRoot = getGitRoot();
const gitRoot = getGitRoot(configPath);
const relativePath = path.relative(gitRoot, configPath);
try {
return shajs("sha256").update(relativePath).digest("hex");
Expand All @@ -47,4 +52,4 @@ export function getConfigurationHash(): string {
} else {
return FALLBACK_NO_CONFIG_HASH;
}
}
}
22 changes: 15 additions & 7 deletions src/scripts/stats/getRepositoryInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@ import shajs from "sha.js";

function azureGetGitRemoteUrl(): string {
if (process.env.BUILD_REPOSITORY_URI) {
return process.env.BUILD_REPOSITORY_URI
return process.env.BUILD_REPOSITORY_URI;
} else {
throw Error();
}
}

function getGitRemoteUrl(): string {
function getGitRemoteUrl(configPath: string): string {
try {
return execSync("git config --get remote.origin.url").toString().trim();
return execSync("git config --get remote.origin.url", {
cwd: configPath, // Run the command in the configPath directory to support absolute path execution
stdio: ["pipe", "pipe", "ignore"] // Ignore stderr
})
.toString()
.trim();
} catch (error) {
// Intentionally left blank
}

try {
return azureGetGitRemoteUrl()
return azureGetGitRemoteUrl();
} catch (error) {
// Intentionally left blank
}
Expand All @@ -30,14 +35,17 @@ export function getCwdGitRemoteUrlHash(): string {
const FALLBACK_HASHING_FAILED = "FALLBACK_HASHING_FAILED";

try {
const remoteUrl = getGitRemoteUrl();
if (!process.env.CONFIG_PATH) {
throw Error();
}
const remoteUrl = getGitRemoteUrl(process.env.CONFIG_PATH);
try {
const remoteUrlHash = shajs("sha256").update(remoteUrl).digest("hex");
return remoteUrlHash;
} catch (error) {
return FALLBACK_HASHING_FAILED;
}
} catch (error) {
return FALLBACK_NO_GIT_ORIGIN_REMOTE
return FALLBACK_NO_GIT_ORIGIN_REMOTE;
}
}
}
31 changes: 24 additions & 7 deletions test/core/dataExchange/specs/importExport.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const formUtils = {
}
},
fillForm: async function (description, userData) {
await closeTrustArcCookiePopup();
await ui5.element.waitForAll(this.textSelector);
await ui5.userInteraction.fill(this.textSelector, description);
await ui5.userInteraction.fill(this.emailSelector, userData.email);
Expand All @@ -47,6 +48,7 @@ const formUtils = {
await ui5.userInteraction.fill(this.urlSelector, userData.website);
},
clearForm: async function () {
await closeTrustArcCookiePopup();
await ui5.userInteraction.clear(this.textSelector);
await ui5.userInteraction.clear(this.emailSelector);
await ui5.userInteraction.clear(this.telephoneSelector);
Expand All @@ -55,6 +57,14 @@ const formUtils = {
}
};

async function closeTrustArcCookiePopup() {
const trustArcCookieButton="//button[text()='Accept All']";
try {
await nonUi5.userInteraction.click(trustArcCookieButton, 30000);
} catch (e) {
// ignore, no cookie dialog
}
}

describe("Import and Export using UI", function () {

Expand All @@ -69,10 +79,9 @@ describe("Import and Export using UI", function () {
// exportData: "./data/ui/export/exportedUser.json",
// webUser : "./data/ui/export/exportedWebUser.json"
// },
it("step 1: use data loaded into myUserPrefix", async function () {

// uses data from file pointed to by myUserPrefix
// myUserPrefix: "./data/ui/user.json",
it("step 1: navigate to app", async function () {

await ui5.navigation.navigateToApplication("", false);
const acceptCookiesButton = {
"elementProperties": {
Expand All @@ -83,12 +92,20 @@ describe("Import and Export using UI", function () {
}]
}
};

await closeTrustArcCookiePopup();
try {
await ui5.userInteraction.click(acceptCookiesButton);
} catch (e) {
// ignore, no cookie dialog
}
await util.browser.switchToIframe("iframe[id='sampleFrame']");
});

it("step 2: use data loaded into myUserPrefix", async function () {

// uses data from file pointed to by myUserPrefix
// myUserPrefix: "./data/ui/user.json",

const userData = browser.params.import.myUserPrefix;
await common.assertion.expectDefined(userData);
Expand All @@ -104,7 +121,7 @@ describe("Import and Export using UI", function () {

});

it("step 2: use data loaded from file in subfolder moreDataFolder - anotherUser.json", async function () {
it("step 3: use data loaded from file in subfolder moreDataFolder - anotherUser.json", async function () {

// file anotherUser.json is in subfolder "moreDataFolder" within directory pointed to by userDataFolder
// userDataFolder: "./data/ui",
Expand All @@ -125,7 +142,7 @@ describe("Import and Export using UI", function () {
await formUtils.clearForm();

});
it("step 3: use data loaded into uiUser", async function () {
it("step 4: use data loaded into uiUser", async function () {

// uses data from file pointed to by reference
// uiUser: "./data/ui/webUser.json"
Expand All @@ -143,7 +160,7 @@ describe("Import and Export using UI", function () {

});

it("step 4: export data into file pointed to by exportData param", async function () {
it("step 5: export data into file pointed to by exportData param", async function () {

const dateAdded = (new Date()).toISOString();
const userData = {
Expand All @@ -168,7 +185,7 @@ describe("Import and Export using UI", function () {

});

it("step 5: export data into file pointed to by webUser param", async function () {
it("step 6: export data into file pointed to by webUser param", async function () {


const dateAdded = (new Date()).toISOString();
Expand Down