Add RunContext support for script outputs (#765)

Resolves #667

This PR:

- Introduces a new field in the project file: `scriptType` which has the
default value of `Class` (in parity with previous versions), but can
also be `RunContext`.
- This is then passed to `InstanceContext` from the `Project` struct.
- This then changes the RunContext in the lua `snapshot_middleware`

---------

Co-authored-by: Micah <dekkonot@rocketmail.com>
This commit is contained in:
Sasial
2023-09-24 06:28:09 +10:00
committed by GitHub
parent 539cd0d418
commit bb8dd1402d
56 changed files with 602 additions and 95 deletions

View File

@@ -44,6 +44,7 @@ gen_build_tests! {
json_model_legacy_name,
module_in_folder,
module_init,
nested_runcontext,
optional,
project_composed_default,
project_composed_file,

View File

@@ -1,6 +1,6 @@
use std::fs;
use insta::assert_yaml_snapshot;
use insta::{assert_yaml_snapshot, with_settings};
use tempfile::tempdir;
use crate::rojo_test::{internable::InternAndRedact, serve_util::run_serve_test};
@@ -30,10 +30,12 @@ fn scripts() {
assert_yaml_snapshot!("scripts_info", redactions.redacted_yaml(info));
let read_response = session.get_api_read(root_id).unwrap();
assert_yaml_snapshot!(
"scripts_all",
read_response.intern_and_redact(&mut redactions, root_id)
);
with_settings!({ sort_maps => true }, {
assert_yaml_snapshot!(
"scripts_all",
read_response.intern_and_redact(&mut redactions, root_id)
);
});
fs::write(session.path().join("src/foo.lua"), "Updated foo!").unwrap();
@@ -44,10 +46,12 @@ fn scripts() {
);
let read_response = session.get_api_read(root_id).unwrap();
assert_yaml_snapshot!(
"scripts_all-2",
read_response.intern_and_redact(&mut redactions, root_id)
);
with_settings!({ sort_maps => true }, {
assert_yaml_snapshot!(
"scripts_all-2",
read_response.intern_and_redact(&mut redactions, root_id)
);
});
});
}