From 26bd3f73f81d2e54243bc72c266fdae96906b8d0 Mon Sep 17 00:00:00 2001 From: Beatriz Rizental Date: Thu, 19 Jan 2023 18:23:25 +0100 Subject: [PATCH] Load production addons on tests --- scripts/addon/generate_all_tests.py | 16 ++++++++++++---- tests/functional/servers/addon.js | 16 +++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/scripts/addon/generate_all_tests.py b/scripts/addon/generate_all_tests.py index 798a3a0c32f..271c1fbb9b5 100755 --- a/scripts/addon/generate_all_tests.py +++ b/scripts/addon/generate_all_tests.py @@ -19,15 +19,23 @@ args = parser.parse_args() generateall_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "generate_all.py") -addons_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "tests", "functional", "addons") -for file in os.listdir(addons_path): - manifest_path = os.path.join(addons_path, file, "manifest.json") +# Generate production addons files +build_cmd = [sys.executable, generateall_path] +if args.qtpath: + build_cmd.append("-q") + build_cmd.append(args.qtpath) +subprocess.call(build_cmd) + +# Generate test addons files +test_addons_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "tests", "functional", "addons") +for file in os.listdir(test_addons_path): + manifest_path = os.path.join(test_addons_path, file, "manifest.json") if os.path.exists(manifest_path): print(f"Ignoring path {file} because the manifest already exists.") continue - build_cmd = [sys.executable, generateall_path, "-p", os.path.join(addons_path, file)] + build_cmd = [sys.executable, generateall_path, "-p", os.path.join(test_addons_path, file)] if args.qtpath: build_cmd.append("-q") build_cmd.append(args.qtpath) diff --git a/tests/functional/servers/addon.js b/tests/functional/servers/addon.js index c51702a0ebb..3ed1337d653 100644 --- a/tests/functional/servers/addon.js +++ b/tests/functional/servers/addon.js @@ -6,7 +6,8 @@ const Server = require('./server.js'); const fs = require('fs'); const path = require('path'); -const ADDON_PATH = './tests/functional/addons'; +const TEST_ADDONS_PATH = './tests/functional/addons'; +const PROD_ADDONS_PATH = './addons'; // This function exposes all the files for a particular addon scenario through // the addon server. @@ -15,8 +16,7 @@ function createScenario(scenario, addonPath) { if (!fs.existsSync(generatedPath)) { const manifestPath = path.join(addonPath, 'manifest.json'); if (!fs.existsSync(manifestPath)) { - throw new Error(`No generated and not manifest file! ${ - manifestPath} should exist! Have you executed \`./scripts/addon/generate_all_tests.py'?`); + throw new Error(`No generated and not manifest file! ${manifestPath} should exist! Have you executed \`./scripts/addon/generate_all_tests.py'?`); } const obj = {}; @@ -65,17 +65,19 @@ function createScenario(scenario, addonPath) { let server = null; module.exports = { async start(headerCheck = true) { - let scenarios = {}; + // Generate production addon scenarios + let scenarios = { ...createScenario("prod", PROD_ADDONS_PATH) }; - const dirs = fs.readdirSync(ADDON_PATH); + // Generate test addon scenarios + const dirs = fs.readdirSync(TEST_ADDONS_PATH); for (const dir of dirs) { - const addonPath = path.join(ADDON_PATH, dir); + const addonPath = path.join(TEST_ADDONS_PATH, dir); const stat = fs.statSync(addonPath); if (!stat.isDirectory()) { continue; } - scenarios = {...scenarios, ...createScenario(dir, addonPath)}; + scenarios = { ...scenarios, ...createScenario(dir, addonPath) }; } const endpoints = {