mirror of
https://github.com/project-gauntlet/gauntlet.git
synced 2025-12-23 10:35:53 +00:00
Fix scenarios not working
This commit is contained in:
parent
a54a760cd4
commit
bbfb17e4b1
6 changed files with 28 additions and 25 deletions
|
|
@ -36,7 +36,6 @@ async function runScenarios(expectedPlugin: string | undefined) {
|
|||
const scenariosRun = path.join(scenarios, "run");
|
||||
|
||||
console.log("Building server")
|
||||
buildServer(projectRoot)
|
||||
|
||||
console.log("Building scenario plugins")
|
||||
buildScenarioPlugins(projectRoot)
|
||||
|
|
@ -50,7 +49,7 @@ async function runScenarios(expectedPlugin: string | undefined) {
|
|||
|
||||
console.log("Starting runner")
|
||||
|
||||
const backendProcess = spawnSync('target/debug/gauntlet', {
|
||||
const backendProcess = spawnSync('cargo', ['run', '--features', 'scenario_runner'], {
|
||||
stdio: "inherit",
|
||||
cwd: projectRoot,
|
||||
env: Object.assign(process.env, {
|
||||
|
|
@ -82,8 +81,6 @@ async function runScreenshotGen(expectedPlugin: string | undefined, expectedEntr
|
|||
const scenarios = path.join(projectRoot, "scenarios");
|
||||
const scenariosOut = path.join(scenarios, "out");
|
||||
|
||||
buildServer(projectRoot)
|
||||
|
||||
for (const plugin of readdirSync(scenariosOut)) {
|
||||
if (expectedPlugin) {
|
||||
if (plugin != expectedPlugin) {
|
||||
|
|
@ -116,10 +113,11 @@ async function runScreenshotGen(expectedPlugin: string | undefined, expectedEntr
|
|||
.map(x => (x.charAt(0).toUpperCase() + x.slice(1)))
|
||||
.join(" ");
|
||||
|
||||
const frontendReturn = spawnSync('target/debug/gauntlet', {
|
||||
const frontendReturn = spawnSync('cargo', ['run', '--features', 'scenario_runner'], {
|
||||
stdio: "inherit",
|
||||
cwd: projectRoot,
|
||||
env: Object.assign(process.env, {
|
||||
RUST_BACKTRACE: "1",
|
||||
RUST_LOG: "gauntlet-client=INFO",
|
||||
GAUNTLET_SCENARIO_RUNNER_TYPE: "screenshot_gen",
|
||||
GAUNTLET_SCREENSHOT_GEN_IN: scenarioFile,
|
||||
|
|
@ -138,20 +136,6 @@ async function runScreenshotGen(expectedPlugin: string | undefined, expectedEntr
|
|||
}
|
||||
}
|
||||
|
||||
function buildServer(projectRoot: string) {
|
||||
const serverBuildResult = spawnSync('cargo', ['build', '--features', 'scenario_runner'], {
|
||||
stdio: "inherit",
|
||||
cwd: projectRoot,
|
||||
env: Object.assign(process.env, {
|
||||
RUST_BACKTRACE: "1"
|
||||
})
|
||||
});
|
||||
|
||||
if (serverBuildResult.status !== 0) {
|
||||
throw new Error(`Unable to compile server, status: ${JSON.stringify(serverBuildResult)}`);
|
||||
}
|
||||
}
|
||||
|
||||
function buildScenarioPlugins(projectRoot: string) {
|
||||
const scenarioPluginBuildResult = spawnSync('npm', ['run', 'build-all'], {
|
||||
stdio: "inherit",
|
||||
|
|
|
|||
|
|
@ -404,6 +404,8 @@ fn new(
|
|||
let gen_in = std::env::var("GAUNTLET_SCREENSHOT_GEN_IN")
|
||||
.expect("Unable to read GAUNTLET_SCREENSHOT_GEN_IN");
|
||||
|
||||
println!("Reading scenario file at: {}", gen_in);
|
||||
|
||||
let gen_in = fs::read_to_string(gen_in)
|
||||
.expect("Unable to read file at GAUNTLET_SCREENSHOT_GEN_IN");
|
||||
|
||||
|
|
|
|||
|
|
@ -558,7 +558,7 @@ fn component_model_generator() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
output.push_str("#[derive(Debug, Serialize, Deserialize, Encode, Decode)]\n");
|
||||
output.push_str("pub struct RootWidget {\n");
|
||||
output.push_str(" #[serde(default, deserialize_with = \"array_to_option\")]\n");
|
||||
output.push_str(" #[serde(default, deserialize_with = \"array_to_option\", serialize_with = \"option_to_array\")]\n");
|
||||
output.push_str(" pub content: Option<RootWidgetMembers>\n");
|
||||
output.push_str("}\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,6 +245,21 @@ pub enum KeyboardEventOrigin {
|
|||
PluginView,
|
||||
}
|
||||
|
||||
fn option_to_array<S, V>(value: &Option<V>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
V: Serialize,
|
||||
S: Serializer,
|
||||
{
|
||||
let value = match value {
|
||||
None => vec![],
|
||||
Some(value) => vec![value]
|
||||
};
|
||||
|
||||
let res = Vec::<&V>::serialize(&value, serializer)?;
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
fn array_to_option<'de, D, V>(deserializer: D) -> Result<Option<V>, D::Error> where D: Deserializer<'de>, V: Deserialize<'de> {
|
||||
let res = Option::<Vec<V>>::deserialize(deserializer)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use vergen_gitcl::{CargoBuilder, Emitter, GitclBuilder};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("cargo:rerun-if-changed=src/db_migrations");
|
||||
println!("cargo:rerun-if-changed=db_migrations");
|
||||
|
||||
let gitcl = GitclBuilder::all_git()?;
|
||||
let cargo = CargoBuilder::default()
|
||||
|
|
|
|||
|
|
@ -257,15 +257,17 @@ pub async fn start_plugin_runtime(data: PluginRuntimeData, run_status_guard: Run
|
|||
let current_exe = std::env::current_exe()
|
||||
.context("unable to get current_exe")?;
|
||||
|
||||
#[cfg(not(feature = "scenario_runner"))]
|
||||
std::process::Command::new(current_exe)
|
||||
.env(PLUGIN_RUNTIME_ENV, name_str)
|
||||
.spawn()
|
||||
.context("start plugin runtime process")?;
|
||||
|
||||
// use only for debugging, only works if only one plugin is enabled
|
||||
// std::thread::spawn(move || {
|
||||
// plugin_runtime::run_plugin_runtime(name_str.to_str().unwrap().to_string())
|
||||
// });
|
||||
// use only for debugging and scenario_runner, only works if only one plugin is enabled
|
||||
#[cfg(feature = "scenario_runner")]
|
||||
std::thread::spawn(move || {
|
||||
gauntlet_plugin_runtime::run_plugin_runtime(name_str.to_str().unwrap().to_string())
|
||||
});
|
||||
|
||||
let conn = listener.accept().await?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue