- platform/layout : racine sequa-root.json, chemins des composants, arguments et chemins en UTF-8.
- Règles install() : bin/windows-x64/{debug,release,asan}/ (core, render, studio + ui, engines).
- Le Core trouve sequa-render et les adaptateurs depuis la racine (--sequa-root, passé par
Studio host à sa copie fantôme) : plus de render-unavailable depuis le panneau Rendu.
- L'adaptateur Godot cherche Godot et son projet à côté de lui (surcharge par --adapter-options) ;
template_release pour le type release. Godot hébergé dans les presets debug et release.
- scripts/build-all.ps1 : Godot, C++, interface, arrêt des processus du dossier visé, install ;
check.ps1 l'appelle (modification de l'ADR 0004).
- docs/installation/ : compiler, lancer, installer et désinstaller par plateforme.
116 lines
4.2 KiB
C++
116 lines
4.2 KiB
C++
// SPDX-License-Identifier: MPL-2.0
|
|
#include "options.hpp"
|
|
|
|
#include <doctest/doctest.h>
|
|
|
|
#include "sequa/platform/layout.hpp"
|
|
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
using namespace sequa::studio::host;
|
|
|
|
namespace {
|
|
|
|
ParsedOptions parse(std::vector<std::string_view> args)
|
|
{
|
|
return parse_options(args);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("Options : valeurs par defaut")
|
|
{
|
|
const auto parsed = parse({});
|
|
REQUIRE(parsed.options.has_value());
|
|
CHECK(parsed.options->core_port == 9100);
|
|
CHECK(parsed.options->ui_port == 9180);
|
|
CHECK_FALSE(parsed.options->dev_url.has_value());
|
|
CHECK_FALSE(parsed.options->watch);
|
|
}
|
|
|
|
TEST_CASE("Options : toutes les options")
|
|
{
|
|
const auto parsed = parse({"--core-exe", "C:/x/sequa-core.exe", "--core-port", "9200", "--ui-port", "9280",
|
|
"--dev", "http://localhost:5174", "--detach-core", "--no-browser", "--core-console",
|
|
"--watch", "--ui-dir", "dist"});
|
|
REQUIRE(parsed.options.has_value());
|
|
const auto& options = *parsed.options;
|
|
CHECK(options.core_exe == std::filesystem::path("C:/x/sequa-core.exe"));
|
|
CHECK(options.core_port == 9200);
|
|
CHECK(options.ui_port == 9280);
|
|
CHECK(options.dev_url == "http://localhost:5174");
|
|
CHECK(options.detach_core);
|
|
CHECK(options.no_browser);
|
|
CHECK(options.core_console);
|
|
CHECK(options.watch);
|
|
CHECK(options.ui_dir == std::filesystem::path("dist"));
|
|
}
|
|
|
|
TEST_CASE("Options : --dev sans URL")
|
|
{
|
|
const auto parsed = parse({"--dev", "--watch"});
|
|
REQUIRE(parsed.options.has_value());
|
|
CHECK(parsed.options->dev_url == "http://localhost:5173");
|
|
CHECK(parsed.options->watch);
|
|
}
|
|
|
|
TEST_CASE("Options : erreurs")
|
|
{
|
|
CHECK_FALSE(parse({"--core-port", "0"}).options.has_value());
|
|
CHECK_FALSE(parse({"--core-port", "70000"}).options.has_value());
|
|
CHECK_FALSE(parse({"--core-port", "91a"}).options.has_value());
|
|
CHECK_FALSE(parse({"--core-port"}).options.has_value());
|
|
CHECK_FALSE(parse({"--inconnue"}).options.has_value());
|
|
CHECK_FALSE(parse({"--core-port", "9180"}).options.has_value()); // même port que l'interface
|
|
}
|
|
|
|
TEST_CASE("Options : origine d'une URL")
|
|
{
|
|
CHECK(origin_of("http://localhost:5173/") == "http://localhost:5173");
|
|
CHECK(origin_of("https://exemple.com:8443/a?b#c") == "https://exemple.com:8443");
|
|
CHECK(origin_of("http://127.0.0.1:9180") == "http://127.0.0.1:9180");
|
|
CHECK_FALSE(origin_of("ws://127.0.0.1:9100").has_value());
|
|
CHECK_FALSE(origin_of("http://").has_value());
|
|
}
|
|
|
|
TEST_CASE("Options : recherche du Core et de l'interface dans une arborescence avec sequa-root.json")
|
|
{
|
|
const auto root = std::filesystem::temp_directory_path() / "sequa-app-options-test";
|
|
std::filesystem::remove_all(root);
|
|
const auto core_name = sequa::platform::executable_name("sequa-core");
|
|
const auto exe_dir = root / "studio" / "host" / "app";
|
|
std::filesystem::create_directories(exe_dir);
|
|
std::filesystem::create_directories(root / "core");
|
|
std::filesystem::create_directories(root / "studio" / "ui");
|
|
std::ofstream(root / "sequa-root.json") << "{}";
|
|
std::ofstream(root / "core" / core_name) << "x";
|
|
std::ofstream(root / "studio" / "ui" / "index.html") << "<html>";
|
|
|
|
CHECK(find_sequa_root(exe_dir) == root);
|
|
CHECK(find_core_exe(exe_dir) == root / "core" / core_name);
|
|
CHECK(find_ui_dir(exe_dir) == root / "studio" / "ui");
|
|
|
|
std::filesystem::remove_all(root);
|
|
}
|
|
|
|
TEST_CASE("Options : sans sequa-root.json retourne nullopt")
|
|
{
|
|
const auto root = std::filesystem::temp_directory_path() / "sequa-app-options-test-no-root";
|
|
std::filesystem::remove_all(root);
|
|
const auto exe_dir = root / "studio" / "host" / "app";
|
|
std::filesystem::create_directories(exe_dir);
|
|
std::filesystem::create_directories(root / "core");
|
|
std::filesystem::create_directories(root / "studio" / "ui");
|
|
std::ofstream(root / "core" / sequa::platform::executable_name("sequa-core")) << "x";
|
|
std::ofstream(root / "studio" / "ui" / "index.html") << "<html>";
|
|
|
|
CHECK_FALSE(find_sequa_root(exe_dir).has_value());
|
|
CHECK_FALSE(find_core_exe(exe_dir).has_value());
|
|
CHECK_FALSE(find_ui_dir(exe_dir).has_value());
|
|
|
|
std::filesystem::remove_all(root);
|
|
}
|