diff --git a/code/__DEFINES/rust_g.dm b/code/__DEFINES/rust_g.dm index c7b8bca1437..d0352091e65 100644 --- a/code/__DEFINES/rust_g.dm +++ b/code/__DEFINES/rust_g.dm @@ -1,6 +1,9 @@ /// Locator for the RUSTG DLL or SO depending on system type #define RUST_G (world.system_type == UNIX ? "./librust_g.so" : "./rust_g.dll") +// Gets the version of RUSTG +/proc/rustg_get_version() return call(RUST_G, "get_version")() + // Defines for internal job subsystem // #define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET" #define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB" @@ -10,6 +13,7 @@ #define rustg_dmi_strip_metadata(fname) call(RUST_G, "dmi_strip_metadata")(fname) #define rustg_dmi_create_png(path, width, height, data) call(RUST_G, "dmi_create_png")(path, width, height, data) +// Noise related operations // #define rustg_noise_get_at_coordinates(seed, x, y) call(RUST_G, "noise_get_at_coordinates")(seed, x, y) // Git related operations // @@ -43,3 +47,6 @@ #define rustg_sql_connected(handle) call(RUST_G, "sql_connected")(handle) #define rustg_sql_disconnect_pool(handle) call(RUST_G, "sql_disconnect_pool")(handle) #define rustg_sql_check_query(job_id) call(RUST_G, "sql_check_query")("[job_id]") + +// RUSTG Version // +#define RUST_G_VERSION "0.4.5-P2" diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 80467d19846..4f8cc28d54b 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -3,8 +3,10 @@ #ifdef UNIT_TESTS #include "component_tests.dm" +#include "log_format.dm" #include "map_templates.dm" #include "reagent_id_typos.dm" +#include "rustg_version.dm" #include "spawn_humans.dm" #include "sql.dm" #include "subsystem_init.dm" diff --git a/code/modules/unit_tests/log_format.dm b/code/modules/unit_tests/log_format.dm new file mode 100644 index 00000000000..d774614fba2 --- /dev/null +++ b/code/modules/unit_tests/log_format.dm @@ -0,0 +1,26 @@ +// This exists so that logs are the designated format. If they arent, it breaks logging tooling. Also 8601 is king. +#define TEST_MESSAGE "Log time format test" +#define TEST_LOG_FILE "data/ci_testing.log" + +/proc/generate_test_log_message(time) + var/date_portion = time2text(time, "YYYY-MM-DD") + var/time_portion = time2text(time, "hh:mm:ss") + return "\[[date_portion]T[time_portion]] [TEST_MESSAGE]" + + +/datum/unit_test/rustg_version/Run() + // Generate a list of valid log timestamps. It can be the current time, or up to 2 seconds later to account for spurious CI lag + var/valid_lines = list( + "[generate_test_log_message(world.timeofday)]", + "[generate_test_log_message(world.timeofday + 10)]", + "[generate_test_log_message(world.timeofday + 20)]", + ) + + rustg_log_write(TEST_LOG_FILE, TEST_MESSAGE) + + var/list/lines = file2list(TEST_LOG_FILE) + if(!(lines[1] in valid_lines)) + Fail("RUSTG log format is not valid 8601 format. Expected '[generate_test_log_message(world.timeofday)]', got '[lines[1]]'") + +#undef TEST_MESSAGE +#undef TEST_LOG_FILE diff --git a/code/modules/unit_tests/rustg_version.dm b/code/modules/unit_tests/rustg_version.dm new file mode 100644 index 00000000000..626e481c39b --- /dev/null +++ b/code/modules/unit_tests/rustg_version.dm @@ -0,0 +1,4 @@ +/datum/unit_test/rustg_version/Run() + var/library_version = rustg_get_version() + if(library_version != RUST_G_VERSION) + Fail("Invalid RUSTG Version. Library is [library_version], but in-code API is [RUST_G_VERSION]") diff --git a/librust_g.so b/librust_g.so index d5c25f422d2..82e02cd17d8 100644 Binary files a/librust_g.so and b/librust_g.so differ diff --git a/rust_g.dll b/rust_g.dll index 8e80d194a08..bb414674e2e 100644 Binary files a/rust_g.dll and b/rust_g.dll differ