Skip to content

Commit

Permalink
Load production addons on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brizental committed Jan 30, 2023
1 parent 5aeeffe commit cfd5bf2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
16 changes: 12 additions & 4 deletions scripts/addon/generate_all_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 9 additions & 7 deletions tests/functional/servers/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 = {};
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit cfd5bf2

Please sign in to comment.