2023-07-20 08:47:00 +01:00
|
|
|
use std::process::ExitCode;
|
2023-02-10 11:14:28 +00:00
|
|
|
|
|
|
|
use anyhow::Result;
|
|
|
|
use console::set_colors_enabled;
|
|
|
|
use console::set_colors_enabled_stderr;
|
|
|
|
use tokio::fs::read_to_string;
|
|
|
|
|
2024-01-14 09:41:18 +00:00
|
|
|
use crate::Runtime;
|
2023-02-10 11:14:28 +00:00
|
|
|
|
|
|
|
const ARGS: &[&str] = &["Foo", "Bar"];
|
|
|
|
|
|
|
|
macro_rules! create_tests {
|
|
|
|
($($name:ident: $value:expr,)*) => { $(
|
2023-02-13 14:28:18 +00:00
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
2023-02-10 11:14:28 +00:00
|
|
|
async fn $name() -> Result<ExitCode> {
|
|
|
|
// Disable styling for stdout and stderr since
|
|
|
|
// some tests rely on output not being styled
|
|
|
|
set_colors_enabled(false);
|
|
|
|
set_colors_enabled_stderr(false);
|
|
|
|
// The rest of the test logic can continue as normal
|
|
|
|
let full_name = format!("tests/{}.luau", $value);
|
|
|
|
let script = read_to_string(&full_name).await?;
|
2024-01-14 09:41:18 +00:00
|
|
|
let mut lune = Runtime::new().with_args(
|
2023-02-10 11:14:28 +00:00
|
|
|
ARGS
|
|
|
|
.clone()
|
|
|
|
.iter()
|
|
|
|
.map(ToString::to_string)
|
2023-02-17 18:20:17 +00:00
|
|
|
.collect::<Vec<_>>()
|
2023-02-10 11:14:28 +00:00
|
|
|
);
|
2023-02-26 12:59:34 +00:00
|
|
|
let script_name = full_name
|
|
|
|
.trim_end_matches(".luau")
|
|
|
|
.trim_end_matches(".lua")
|
|
|
|
.to_string();
|
2023-03-21 14:06:28 +00:00
|
|
|
let exit_code = lune.run(&script_name, &script).await?;
|
2023-02-10 11:14:28 +00:00
|
|
|
Ok(exit_code)
|
|
|
|
}
|
|
|
|
)* }
|
|
|
|
}
|
|
|
|
|
|
|
|
create_tests! {
|
2023-09-16 05:24:05 +01:00
|
|
|
datetime_format_local_time: "datetime/formatLocalTime",
|
|
|
|
datetime_format_universal_time: "datetime/formatUniversalTime",
|
|
|
|
datetime_from_iso_date: "datetime/fromIsoDate",
|
|
|
|
datetime_from_local_time: "datetime/fromLocalTime",
|
|
|
|
datetime_from_universal_time: "datetime/fromUniversalTime",
|
|
|
|
datetime_from_unix_timestamp: "datetime/fromUnixTimestamp",
|
|
|
|
datetime_now: "datetime/now",
|
|
|
|
datetime_to_iso_date: "datetime/toIsoDate",
|
|
|
|
datetime_to_local_time: "datetime/toLocalTime",
|
|
|
|
datetime_to_universal_time: "datetime/toUniversalTime",
|
|
|
|
|
2023-02-10 11:14:28 +00:00
|
|
|
fs_files: "fs/files",
|
2023-07-20 18:29:21 +01:00
|
|
|
fs_copy: "fs/copy",
|
2023-02-10 11:14:28 +00:00
|
|
|
fs_dirs: "fs/dirs",
|
2023-07-20 11:25:36 +01:00
|
|
|
fs_metadata: "fs/metadata",
|
2023-02-23 09:20:57 +00:00
|
|
|
fs_move: "fs/move",
|
2023-06-12 07:51:14 +01:00
|
|
|
|
2023-08-12 01:17:48 +01:00
|
|
|
luau_compile: "luau/compile",
|
|
|
|
luau_load: "luau/load",
|
|
|
|
luau_options: "luau/options",
|
|
|
|
|
2023-02-10 11:14:28 +00:00
|
|
|
net_request_codes: "net/request/codes",
|
2023-06-12 09:00:00 +01:00
|
|
|
net_request_compression: "net/request/compression",
|
2023-02-10 11:14:28 +00:00
|
|
|
net_request_methods: "net/request/methods",
|
2023-02-23 10:31:42 +00:00
|
|
|
net_request_query: "net/request/query",
|
2023-02-10 11:14:28 +00:00
|
|
|
net_request_redirect: "net/request/redirect",
|
2023-03-21 16:48:07 +00:00
|
|
|
net_url_encode: "net/url/encode",
|
|
|
|
net_url_decode: "net/url/decode",
|
2023-08-20 22:20:45 +01:00
|
|
|
net_serve_requests: "net/serve/requests",
|
|
|
|
net_serve_websockets: "net/serve/websockets",
|
2023-06-15 21:36:05 +01:00
|
|
|
net_socket_wss: "net/socket/wss",
|
2023-07-19 18:30:27 +01:00
|
|
|
net_socket_wss_rw: "net/socket/wss_rw",
|
2023-06-12 07:51:14 +01:00
|
|
|
|
2023-02-10 11:14:28 +00:00
|
|
|
process_args: "process/args",
|
|
|
|
process_cwd: "process/cwd",
|
|
|
|
process_env: "process/env",
|
|
|
|
process_exit: "process/exit",
|
2023-10-06 02:53:29 +01:00
|
|
|
process_spawn_async: "process/spawn/async",
|
|
|
|
process_spawn_basic: "process/spawn/basic",
|
|
|
|
process_spawn_cwd: "process/spawn/cwd",
|
|
|
|
process_spawn_shell: "process/spawn/shell",
|
|
|
|
process_spawn_stdin: "process/spawn/stdin",
|
|
|
|
process_spawn_stdio: "process/spawn/stdio",
|
2023-06-12 07:51:14 +01:00
|
|
|
|
2024-01-14 12:33:15 +00:00
|
|
|
require_aliases: "require/tests/aliases",
|
2023-03-22 17:16:45 +00:00
|
|
|
require_async: "require/tests/async",
|
2023-08-22 20:59:27 +01:00
|
|
|
require_async_background: "require/tests/async_background",
|
2023-03-22 17:16:45 +00:00
|
|
|
require_async_concurrent: "require/tests/async_concurrent",
|
|
|
|
require_async_sequential: "require/tests/async_sequential",
|
|
|
|
require_builtins: "require/tests/builtins",
|
|
|
|
require_children: "require/tests/children",
|
2023-07-20 07:38:19 +01:00
|
|
|
require_init: "require/tests/init",
|
2023-03-22 17:16:45 +00:00
|
|
|
require_invalid: "require/tests/invalid",
|
2023-08-04 22:58:18 +01:00
|
|
|
require_multi_ext: "require/tests/multi_ext",
|
2023-03-22 17:16:45 +00:00
|
|
|
require_nested: "require/tests/nested",
|
|
|
|
require_parents: "require/tests/parents",
|
|
|
|
require_siblings: "require/tests/siblings",
|
2023-06-12 07:51:14 +01:00
|
|
|
|
2023-04-29 10:02:46 +01:00
|
|
|
global_g_table: "globals/_G",
|
2023-08-19 23:27:42 +01:00
|
|
|
global_version: "globals/_VERSION",
|
|
|
|
global_coroutine: "globals/coroutine",
|
2023-08-22 01:10:20 +01:00
|
|
|
global_error: "globals/error",
|
2023-02-17 14:03:13 +00:00
|
|
|
global_pcall: "globals/pcall",
|
|
|
|
global_type: "globals/type",
|
|
|
|
global_typeof: "globals/typeof",
|
2023-08-21 02:02:01 +01:00
|
|
|
global_warn: "globals/warn",
|
2023-06-12 07:51:14 +01:00
|
|
|
|
|
|
|
serde_compression_files: "serde/compression/files",
|
|
|
|
serde_compression_roundtrip: "serde/compression/roundtrip",
|
2023-03-21 15:48:28 +00:00
|
|
|
serde_json_decode: "serde/json/decode",
|
|
|
|
serde_json_encode: "serde/json/encode",
|
|
|
|
serde_toml_decode: "serde/toml/decode",
|
|
|
|
serde_toml_encode: "serde/toml/encode",
|
2023-06-12 07:51:14 +01:00
|
|
|
|
2023-02-10 11:14:28 +00:00
|
|
|
stdio_format: "stdio/format",
|
|
|
|
stdio_color: "stdio/color",
|
|
|
|
stdio_style: "stdio/style",
|
|
|
|
stdio_write: "stdio/write",
|
|
|
|
stdio_ewrite: "stdio/ewrite",
|
2023-06-12 07:51:14 +01:00
|
|
|
|
2023-02-10 11:14:28 +00:00
|
|
|
task_cancel: "task/cancel",
|
|
|
|
task_defer: "task/defer",
|
|
|
|
task_delay: "task/delay",
|
|
|
|
task_spawn: "task/spawn",
|
|
|
|
task_wait: "task/wait",
|
|
|
|
}
|
2023-03-21 18:13:41 +00:00
|
|
|
|
|
|
|
#[cfg(feature = "roblox")]
|
|
|
|
create_tests! {
|
2023-03-22 13:12:05 +00:00
|
|
|
roblox_datatype_axes: "roblox/datatypes/Axes",
|
|
|
|
roblox_datatype_brick_color: "roblox/datatypes/BrickColor",
|
|
|
|
roblox_datatype_cframe: "roblox/datatypes/CFrame",
|
|
|
|
roblox_datatype_color3: "roblox/datatypes/Color3",
|
|
|
|
roblox_datatype_color_sequence: "roblox/datatypes/ColorSequence",
|
|
|
|
roblox_datatype_color_sequence_keypoint: "roblox/datatypes/ColorSequenceKeypoint",
|
|
|
|
roblox_datatype_enum: "roblox/datatypes/Enum",
|
|
|
|
roblox_datatype_faces: "roblox/datatypes/Faces",
|
|
|
|
roblox_datatype_font: "roblox/datatypes/Font",
|
|
|
|
roblox_datatype_number_range: "roblox/datatypes/NumberRange",
|
|
|
|
roblox_datatype_number_sequence: "roblox/datatypes/NumberSequence",
|
|
|
|
roblox_datatype_number_sequence_keypoint: "roblox/datatypes/NumberSequenceKeypoint",
|
|
|
|
roblox_datatype_physical_properties: "roblox/datatypes/PhysicalProperties",
|
|
|
|
roblox_datatype_ray: "roblox/datatypes/Ray",
|
|
|
|
roblox_datatype_rect: "roblox/datatypes/Rect",
|
|
|
|
roblox_datatype_udim: "roblox/datatypes/UDim",
|
|
|
|
roblox_datatype_udim2: "roblox/datatypes/UDim2",
|
|
|
|
roblox_datatype_region3: "roblox/datatypes/Region3",
|
|
|
|
roblox_datatype_region3int16: "roblox/datatypes/Region3int16",
|
|
|
|
roblox_datatype_vector2: "roblox/datatypes/Vector2",
|
|
|
|
roblox_datatype_vector2int16: "roblox/datatypes/Vector2int16",
|
|
|
|
roblox_datatype_vector3: "roblox/datatypes/Vector3",
|
|
|
|
roblox_datatype_vector3int16: "roblox/datatypes/Vector3int16",
|
2023-03-26 08:38:59 +01:00
|
|
|
|
2023-05-20 13:23:51 +01:00
|
|
|
roblox_files_deserialize_model: "roblox/files/deserializeModel",
|
|
|
|
roblox_files_deserialize_place: "roblox/files/deserializePlace",
|
|
|
|
roblox_files_serialize_model: "roblox/files/serializeModel",
|
|
|
|
roblox_files_serialize_place: "roblox/files/serializePlace",
|
2023-03-26 08:38:59 +01:00
|
|
|
|
2023-03-25 10:39:32 +00:00
|
|
|
roblox_instance_attributes: "roblox/instance/attributes",
|
2023-03-22 13:12:05 +00:00
|
|
|
roblox_instance_new: "roblox/instance/new",
|
|
|
|
roblox_instance_properties: "roblox/instance/properties",
|
2023-03-26 08:38:59 +01:00
|
|
|
roblox_instance_tags: "roblox/instance/tags",
|
|
|
|
|
2023-03-27 14:59:06 +01:00
|
|
|
roblox_instance_classes_data_model: "roblox/instance/classes/DataModel",
|
|
|
|
roblox_instance_classes_workspace: "roblox/instance/classes/Workspace",
|
2023-08-25 00:39:13 +01:00
|
|
|
roblox_instance_classes_terrain: "roblox/instance/classes/Terrain",
|
2023-03-27 14:59:06 +01:00
|
|
|
|
2023-10-09 05:05:19 +01:00
|
|
|
roblox_instance_custom_async: "roblox/instance/custom/async",
|
|
|
|
roblox_instance_custom_methods: "roblox/instance/custom/methods",
|
|
|
|
roblox_instance_custom_properties: "roblox/instance/custom/properties",
|
|
|
|
|
2023-03-25 17:04:19 +00:00
|
|
|
roblox_instance_methods_clear_all_children: "roblox/instance/methods/ClearAllChildren",
|
|
|
|
roblox_instance_methods_clone: "roblox/instance/methods/Clone",
|
|
|
|
roblox_instance_methods_destroy: "roblox/instance/methods/Destroy",
|
|
|
|
roblox_instance_methods_find_first_ancestor: "roblox/instance/methods/FindFirstAncestor",
|
|
|
|
roblox_instance_methods_find_first_ancestor_of_class: "roblox/instance/methods/FindFirstAncestorOfClass",
|
|
|
|
roblox_instance_methods_find_first_ancestor_which_is_a: "roblox/instance/methods/FindFirstAncestorWhichIsA",
|
|
|
|
roblox_instance_methods_find_first_child: "roblox/instance/methods/FindFirstChild",
|
|
|
|
roblox_instance_methods_find_first_child_of_class: "roblox/instance/methods/FindFirstChildOfClass",
|
|
|
|
roblox_instance_methods_find_first_child_which_is_a: "roblox/instance/methods/FindFirstChildWhichIsA",
|
|
|
|
roblox_instance_methods_get_children: "roblox/instance/methods/GetChildren",
|
2023-10-25 10:10:24 +01:00
|
|
|
roblox_instance_methods_get_debug_id: "roblox/instance/methods/GetDebugId",
|
2023-03-25 17:04:19 +00:00
|
|
|
roblox_instance_methods_get_descendants: "roblox/instance/methods/GetDescendants",
|
|
|
|
roblox_instance_methods_get_full_name: "roblox/instance/methods/GetFullName",
|
|
|
|
roblox_instance_methods_is_a: "roblox/instance/methods/IsA",
|
|
|
|
roblox_instance_methods_is_ancestor_of: "roblox/instance/methods/IsAncestorOf",
|
|
|
|
roblox_instance_methods_is_descendant_of: "roblox/instance/methods/IsDescendantOf",
|
2023-05-26 08:38:11 +01:00
|
|
|
|
|
|
|
roblox_misc_typeof: "roblox/misc/typeof",
|
2023-07-21 11:10:56 +01:00
|
|
|
|
|
|
|
roblox_reflection_class: "roblox/reflection/class",
|
|
|
|
roblox_reflection_database: "roblox/reflection/database",
|
|
|
|
roblox_reflection_enums: "roblox/reflection/enums",
|
|
|
|
roblox_reflection_property: "roblox/reflection/property",
|
2023-03-21 18:13:41 +00:00
|
|
|
}
|