mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 12:45:05 +00:00
Make .meta.json changes cause scripts to be updated
This commit is contained in:
@@ -245,6 +245,69 @@ mod serve_session {
|
||||
assert_yaml_snapshot!(view_tree(&session.tree(), &mut rm));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_with_meta() {
|
||||
let mut imfs = Imfs::new(NoopFetcher);
|
||||
|
||||
imfs.debug_load_snapshot(
|
||||
"/root",
|
||||
ImfsSnapshot::dir(hashmap! {
|
||||
"test.lua" => ImfsSnapshot::file("This is a test."),
|
||||
"test.meta.json" => ImfsSnapshot::file(r#"{ "ignoreUnknownInstances": true }"#),
|
||||
}),
|
||||
);
|
||||
|
||||
let session = ServeSession::new(imfs, "/root", None);
|
||||
|
||||
let mut rm = RedactionMap::new();
|
||||
assert_yaml_snapshot!(view_tree(&session.tree(), &mut rm));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn change_script_meta() {
|
||||
let (state, fetcher) = TestFetcher::new();
|
||||
|
||||
state.load_snapshot(
|
||||
"/root",
|
||||
ImfsSnapshot::dir(hashmap! {
|
||||
"test.lua" => ImfsSnapshot::file("This is a test."),
|
||||
"test.meta.json" => ImfsSnapshot::file(r#"{ "ignoreUnknownInstances": true }"#),
|
||||
}),
|
||||
);
|
||||
|
||||
let imfs = Imfs::new(fetcher);
|
||||
let session = ServeSession::new(imfs, "/root", None);
|
||||
|
||||
let mut redactions = RedactionMap::new();
|
||||
assert_yaml_snapshot!(
|
||||
"change_script_meta_before",
|
||||
view_tree(&session.tree(), &mut redactions)
|
||||
);
|
||||
|
||||
state.load_snapshot(
|
||||
"/root/test.meta.json",
|
||||
ImfsSnapshot::file(r#"{ "ignoreUnknownInstances": false }"#),
|
||||
);
|
||||
|
||||
let receiver = Timeout::new(
|
||||
session.message_queue().subscribe_any(),
|
||||
Duration::from_millis(200),
|
||||
);
|
||||
state.raise_event(ImfsEvent::Modified(PathBuf::from("/root/test.meta.json")));
|
||||
|
||||
let mut rt = Runtime::new().unwrap();
|
||||
let changes = rt.block_on(receiver).unwrap();
|
||||
|
||||
assert_yaml_snapshot!(
|
||||
"change_script_meta_patch",
|
||||
redactions.redacted_yaml(changes)
|
||||
);
|
||||
assert_yaml_snapshot!(
|
||||
"change_script_meta_after",
|
||||
view_tree(&session.tree(), &mut redactions)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn change_txt_file() {
|
||||
let (state, fetcher) = TestFetcher::new();
|
||||
|
||||
@@ -96,7 +96,7 @@ fn snapshot_lua_file<F: ImfsFetcher>(
|
||||
|
||||
let mut metadata = InstanceMetadata {
|
||||
instigating_source: Some(entry.path().to_path_buf().into()),
|
||||
relevant_paths: vec![entry.path().to_path_buf()],
|
||||
relevant_paths: vec![entry.path().to_path_buf(), meta_path.clone()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo.client.lua
|
||||
relevant_paths:
|
||||
- /foo.client.lua
|
||||
- /foo.meta.json
|
||||
name: foo
|
||||
class_name: LocalScript
|
||||
properties:
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo.lua
|
||||
relevant_paths:
|
||||
- /foo.lua
|
||||
- /foo.meta.json
|
||||
name: foo
|
||||
class_name: ModuleScript
|
||||
properties:
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo.lua
|
||||
relevant_paths:
|
||||
- /foo.lua
|
||||
- /foo.meta.json
|
||||
name: foo
|
||||
class_name: ModuleScript
|
||||
properties:
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo.server.lua
|
||||
relevant_paths:
|
||||
- /foo.server.lua
|
||||
- /foo.meta.json
|
||||
name: foo
|
||||
class_name: Script
|
||||
properties:
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo.server.lua
|
||||
relevant_paths:
|
||||
- /foo.server.lua
|
||||
- /foo.meta.json
|
||||
name: foo
|
||||
class_name: Script
|
||||
properties:
|
||||
|
||||
30
src/snapshots/serve_session__change_script_meta_after.snap
Normal file
30
src/snapshots/serve_session__change_script_meta_after.snap
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/serve_session.rs
|
||||
expression: "view_tree(&session.tree(), &mut redactions)"
|
||||
---
|
||||
id: id-1
|
||||
name: root
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
instigating_source:
|
||||
Path: /root
|
||||
relevant_paths:
|
||||
- /root
|
||||
children:
|
||||
- id: id-2
|
||||
name: test
|
||||
class_name: ModuleScript
|
||||
properties:
|
||||
Source:
|
||||
Type: String
|
||||
Value: This is a test.
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
instigating_source:
|
||||
Path: /root/test.lua
|
||||
relevant_paths:
|
||||
- /root/test.lua
|
||||
- /root/test.meta.json
|
||||
children: []
|
||||
30
src/snapshots/serve_session__change_script_meta_before.snap
Normal file
30
src/snapshots/serve_session__change_script_meta_before.snap
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/serve_session.rs
|
||||
expression: "view_tree(&session.tree(), &mut redactions)"
|
||||
---
|
||||
id: id-1
|
||||
name: root
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
instigating_source:
|
||||
Path: /root
|
||||
relevant_paths:
|
||||
- /root
|
||||
children:
|
||||
- id: id-2
|
||||
name: test
|
||||
class_name: ModuleScript
|
||||
properties:
|
||||
Source:
|
||||
Type: String
|
||||
Value: This is a test.
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
instigating_source:
|
||||
Path: /root/test.lua
|
||||
relevant_paths:
|
||||
- /root/test.lua
|
||||
- /root/test.meta.json
|
||||
children: []
|
||||
19
src/snapshots/serve_session__change_script_meta_patch.snap
Normal file
19
src/snapshots/serve_session__change_script_meta_patch.snap
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
source: src/serve_session.rs
|
||||
expression: redactions.redacted_yaml(changes)
|
||||
---
|
||||
- 1
|
||||
- - removed: []
|
||||
added: []
|
||||
updated:
|
||||
- id: id-2
|
||||
changed_name: ~
|
||||
changed_class_name: ~
|
||||
changed_properties: {}
|
||||
changed_metadata:
|
||||
ignore_unknown_instances: false
|
||||
instigating_source:
|
||||
Path: /root/test.lua
|
||||
relevant_paths:
|
||||
- /root/test.lua
|
||||
- /root/test.meta.json
|
||||
30
src/snapshots/serve_session__script_with_meta.snap
Normal file
30
src/snapshots/serve_session__script_with_meta.snap
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
source: src/serve_session.rs
|
||||
expression: "view_tree(&session.tree(), &mut rm)"
|
||||
---
|
||||
id: id-1
|
||||
name: root
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
instigating_source:
|
||||
Path: /root
|
||||
relevant_paths:
|
||||
- /root
|
||||
children:
|
||||
- id: id-2
|
||||
name: test
|
||||
class_name: ModuleScript
|
||||
properties:
|
||||
Source:
|
||||
Type: String
|
||||
Value: This is a test.
|
||||
metadata:
|
||||
ignore_unknown_instances: true
|
||||
instigating_source:
|
||||
Path: /root/test.lua
|
||||
relevant_paths:
|
||||
- /root/test.lua
|
||||
- /root/test.meta.json
|
||||
children: []
|
||||
Reference in New Issue
Block a user