Skip to content
Snippets Groups Projects
Commit 47045bca authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette] fix launching scripts

parent 12801d98
No related branches found
No related tags found
No related merge requests found
/* ************************************************************************ */
/* */
/* This file is part of Frama-C. */
/* */
/* Copyright (C) 2007-2023 */
/* CEA (Commissariat à l'énergie atomique et aux énergies */
/* alternatives) */
/* */
/* you can redistribute it and/or modify it under the terms of the GNU */
/* Lesser General Public License as published by the Free Software */
/* Foundation, version 2.1. */
/* */
/* It is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */
/* */
/* See the GNU Lesser General Public License version 2.1 */
/* for more details (enclosed in the file licenses/LGPLv2.1). */
/* */
/* ************************************************************************ */
import { test } from "@playwright/test";
import * as e2eService from "../libs/e2eService";
test("launch app", async () => {
const launchAppResult = await e2eService.launchApp(
e2eService.argsDefaultLaunch,
);
const electronApp = launchAppResult.app;
const window = launchAppResult.page;
await window.screenshot({ path: "screenshots/e2e-app-launch.png" });
// Exit app.
await electronApp.close();
});
......@@ -24,14 +24,10 @@ import { test } from "@playwright/test";
import * as e2eService from "../libs/e2eService";
test("server connection with a C file to analyze", async () => {
const launchAppResult = await e2eService.launchApp(
e2eService.argsLaunchWithTestFile,
);
const launchAppResult =
await e2eService.launchIvette("../tests/test/adpcm.c");
const electronApp = launchAppResult.app;
const window = launchAppResult.page;
await e2eService.testFileIsLoaded(window);
// Exit app.
await e2eService.testFileIsLoaded(window, "../tests/test/adpcm.c");
await electronApp.close();
});
......@@ -24,14 +24,9 @@ import { test } from "@playwright/test";
import * as e2eService from "../libs/e2eService";
test("check server connection", async () => {
const launchAppResult = await e2eService.launchApp(
e2eService.argsLaunchWithDefaultSettings,
);
const launchAppResult = await e2eService.launchIvette();
const electronApp = launchAppResult.app;
const window = launchAppResult.page;
await e2eService.testServerIsStarted(window);
// Exit app.
await electronApp.close();
});
......@@ -24,41 +24,20 @@ import { ElectronApplication, Page, expect } from "@playwright/test";
import { _electron as electron } from "playwright-core";
import * as locs from "./locatorsUtil";
/**
* Basic Electron configuration for Playwright e2e tests of Ivette
*/
export const argsDefaultLaunch: string[] = [
"./out/main/index.js",
"--no-sandbox",
];
/**
* Electron configuration for Playwright e2e tests of Ivette's default settings
*/
export const argsLaunchWithDefaultSettings: string[] = [
"./out/main/index.js",
"--no-sandbox",
"--settings",
"DEFAULT"
];
/**
* Electron configuration for Playwright e2e tests of Ivette on a C file
*/
export const argsLaunchWithTestFile: string[] = [
"./out/main/index.js",
"--no-sandbox",
"--settings",
"./tests/settings.json",
"../tests/test/adpcm.c",
];
/**
* Basic Electron launch of Ivette for Playwright e2e tests
*/
export async function launchApp(
params: string[]
export async function launchIvette(
...params: string[]
): Promise<{ app: ElectronApplication; page: Page }> {
const args: string[] = [
"./out/main/index.js",
"--no-sandbox",
"--settings", "DEFAULT"
];
params.forEach(p => {
p.trim().split(/\s+/).forEach(a => args.push(a));
});
const electronApp = await electron.launch({
env: {
...process.env,
......@@ -87,19 +66,20 @@ export async function testServerIsStarted(window: Page): Promise<void> {
// Check the server status in the console view
await expect(
locs.getConsoleComponent(window)
.getByText("[server] Socket server running.")
.getByText("[server] Socket server running.")
).toBeVisible();
// Check the server status in the footer
await expect(locs.getServerStatusLabel(window)).toHaveText("ON");
}
export async function testFileIsLoaded(window: Page): Promise<void> {
export async function testFileIsLoaded(window: Page, file: string):
Promise<void> {
await locs.getConsoleView(window).click();
// Check if a message is present in the console view to confirm the file is
// loaded
await expect(
locs.getConsoleComponent(window).getByText("adpcm.c (with preprocessing)")
locs.getConsoleComponent(window).getByText(`${file} (with preprocessing)`)
).toBeVisible();
// Check if the main function is visible in the functions view
......
......@@ -28,10 +28,8 @@ let gremlins: any;
test("run gremlins.js", async () => {
test.slow(); // long timeout for a very slow test.
const launchAppResult = await e2eService.launchApp(
e2eService.argsLaunchWithTestFile,
);
const launchAppResult =
await e2eService.launchIvette("../tests/test/adpcm.c");
const electronApp = launchAppResult.app;
const window = launchAppResult.page;
......
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