Skip to content

Commit

Permalink
Adds a helper for running unit tests locally (ParadiseSS13#24269)
Browse files Browse the repository at this point in the history
* adds a helper for running unit tests locally

* warning error

* okay it should be ready

* this shouldnt be here
  • Loading branch information
Contrabang authored Feb 27, 2024
1 parent f4447fc commit 491407c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 10 additions & 2 deletions code/_compile_options.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define DEBUG
//#define TESTING

// Uncomment the following line to compile unit tests.
// #define UNIT_TESTS
// Uncomment the following line to compile unit tests on a local server. The output will be in a test_run-[DATE].log file in the ./data folder.
// #define LOCAL_UNIT_TESTS

// Uncomment the following line to enable Tracy profiling.
// DO NOT DO THIS UNLESS YOU UNDERSTAND THE IMPLICATIONS
Expand All @@ -12,10 +12,18 @@
// Uncomment this to enable support for multiple instances
// #define MULTIINSTANCE

#ifdef LOCAL_UNIT_TESTS
#define UNIT_TESTS
#endif

#ifdef CIBUILDING
#define UNIT_TESTS
#endif

#if defined(CIBUILDING) && defined(LOCAL_UNIT_TESTS)
#error CIBUILDING and LOCAL_UNIT_TESTS should not be enabled at the same time!
#endif

/***** All toggles for the GC ref finder *****/

// #define REFERENCE_TRACKING // Uncomment to enable ref finding
Expand Down
9 changes: 9 additions & 0 deletions code/modules/unit_tests/test_runner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
// intentionally (if there's a lot of legitimate map errors), or accidentally if
// a test condition is written incorrectly and starts e.g. logging failures for
// every single tile.
#ifdef LOCAL_UNIT_TESTS
#define MAX_MAP_TEST_FAILURE_COUNT 100
#else
#define MAX_MAP_TEST_FAILURE_COUNT 20
#endif

/datum/test_runner
var/datum/unit_test/current_test
Expand Down Expand Up @@ -76,6 +80,11 @@
/datum/test_runner/proc/Finalize(emit_failures = FALSE)
var/time = world.timeofday
set waitfor = FALSE

#ifdef LOCAL_UNIT_TESTS
emit_failures = TRUE
#endif

var/list/fail_reasons
if(GLOB)
if(GLOB.total_runtimes != 0)
Expand Down

0 comments on commit 491407c

Please sign in to comment.