Skip to content

Commit

Permalink
skipped TFE & update most unit test stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
LetterN committed Mar 18, 2024
1 parent e897561 commit 7483389
Show file tree
Hide file tree
Showing 43 changed files with 148 additions and 1,285 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ jobs:
- name: Run Grep Checks
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: bash tools/ci/check_grep.sh
- name: Ticked File Enforcement
if: steps.linter-setup.conclusion == 'success' && !cancelled()
# - name: Ticked File Enforcement
# if: steps.linter-setup.conclusion == 'success' && !cancelled()
# add if needed => tools/bootstrap/python tools/ticked_file_enforcement/ticked_file_enforcement.py < tools/ticked_file_enforcement/schemas/tgstation_dme.json
run: tools/bootstrap/python tools/ticked_file_enforcement/ticked_file_enforcement.py < tools/ticked_file_enforcement/schemas/unit_tests.json
# run: tools/bootstrap/python tools/ticked_file_enforcement/ticked_file_enforcement.py < tools/ticked_file_enforcement/schemas/unit_tests.json
# this would be nice cleaning up local defines
# - name: Check Define Sanity
# if: steps.linter-setup.conclusion == 'success' && !cancelled()
Expand Down
38 changes: 27 additions & 11 deletions code/__DEFINES/unit_tests.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Are tests enabled with no focus?
* Use this when performing test assertions outside of a unit test,
* since a focused test means that you're trying to run a test quickly.
* If a parameter is provided, will check if the focus is on that test name.
* For example, PERFORM_ALL_TESTS(log_mapping) will only run if either
* no test is focused, or the focus is log_mapping.
*/
/// Are tests enabled with no focus?
/// Use this when performing test assertions outside of a unit test,
/// since a focused test means that you're trying to run a test quickly.
/// If a parameter is provided, will check if the focus is on that test name.
/// For example, PERFORM_ALL_TESTS(log_mapping) will only run if either
/// no test is focused, or the focus is log_mapping.
#ifdef UNIT_TESTS
/// Bit of a trick here, if focus isn't passed in then it'll check for /datum/unit_test/, which is never the case.
#define PERFORM_ALL_TESTS(focus...) (isnull(GLOB.focused_test) || GLOB.focused_test == /datum/unit_test/##focus)
// Bit of a trick here, if focus isn't passed in then it'll check for /datum/unit_test/, which is never the case.
#define PERFORM_ALL_TESTS(focus...) (isnull(GLOB.focused_tests) || (/datum/unit_test/##focus in GLOB.focused_tests))
#else
/// UNLINT necessary here so that if (PERFORM_ALL_TESTS()) works
// UNLINT necessary here so that if (PERFORM_ALL_TESTS()) works
#define PERFORM_ALL_TESTS(...) UNLINT(FALSE)
#endif

Expand All @@ -20,3 +18,21 @@
#else
#define TEST_ONLY_ASSERT(test, explanation)
#endif

/**
* TODO acutaly make this work
* Used for registering typepaths of item to be tracked as a "required map item"
* This is used to ensure that that all station maps have certain items mapped in that they should have
* Or that people aren't mapping in an excess of items that they shouldn't be
* (For example, all map should only ever have 1 Pun Pun)
*
* Min is inclusive, Max is inclusive (so 1, 1 means min of 1, max of 1, or only 1 allowed)
*
* This should only be used in Initialize(). And don't forget to update the unit test with the type itself!
*/
#ifdef UNIT_TESTS
#define REGISTER_REQUIRED_MAP_ITEM(min, max)
// there was a func here!
#else
#define REGISTER_REQUIRED_MAP_ITEM(min, max)
#endif
3 changes: 3 additions & 0 deletions code/__HELPERS/_logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global"))
SEND_TEXT(world.log, text)

/proc/log_mapping(text)
#ifdef UNIT_TESTS
GLOB.unit_test_mapping_logs += text
#endif
WRITE_LOG(GLOB.world_map_error_log, text)

/**
Expand Down
5 changes: 5 additions & 0 deletions code/_globals/logging.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

#if defined(UNIT_TESTS) || defined(SPACEMAN_DMM)
GLOBAL_VAR(test_log)
#endif

/// Base directory at where logs are placed
GLOBAL_VAR(log_directory)
GLOBAL_PROTECT(log_directory)
Expand Down
27 changes: 22 additions & 5 deletions code/modules/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@
#define TEST_DEFAULT 1
/// After most test steps, used for tests that run long so shorter issues can be noticed faster
#define TEST_LONGER 10
/// This must be the last test to run due to the inherent nature of the test iterating every single tangible atom in the game and qdeleting all of them (while taking long sleeps to make sure the garbage collector fires properly) taking a large amount of time.
#define TEST_CREATE_AND_DESTROY INFINITY
/// This must be the one of last tests to run due to the inherent nature of the test iterating every single tangible atom in the game and qdeleting all of them (while taking long sleeps to make sure the garbage collector fires properly) taking a large amount of time.
#define TEST_CREATE_AND_DESTROY 9001
/**
* For tests that rely on create and destroy having iterated through every (tangible) atom so they don't have to do something similar.
* Keep in mind tho that create and destroy will absolutely break the test platform, anything that relies on its shape cannot come after it.
*/
#define TEST_AFTER_CREATE_AND_DESTROY INFINITY

/// Change color to red on ANSI terminal output, if enabled with -DANSICOLORS.
#ifdef ANSICOLORS
Expand All @@ -70,14 +75,19 @@
#else
#define TEST_OUTPUT_GREEN(text) (text)
#endif

/// Change color to yellow on ANSI terminal output, if enabled with -DANSICOLORS.
#ifdef ANSICOLORS
#define TEST_OUTPUT_YELLOW(text) "\x1B\x5B1;33m[text]\x1B\x5B0m"
#else
#define TEST_OUTPUT_YELLOW(text) (text)
#endif
/// A trait source when adding traits through unit tests
#define TRAIT_SOURCE_UNIT_TESTS "unit_tests"

// BEGIN_INCLUDE
#include "atmospherics/_atmospherics.dm"
#include "core/_core.dm"
#include "datum/_datum.dm"
#include "elements/_elements.dm"
#include "human/_human.dm"
#include "language/_language.dm"
#include "mob/_mob.dm"
Expand All @@ -86,18 +96,25 @@
#include "bad_alcohol_reagents.dm"
#include "bespoke_id.dm"
#include "component_tests.dm"
#include "connect_loc.dm"
#include "focus_only_tests.dm"
#include "initialize_sanity.dm"
#include "loadout_tests.dm"
#include "map_template_paths.dm"
#include "materials.dm"
#include "mapping.dm"
#include "prototypes.dm"
#include "projectiles.dm"
#include "resist.dm"
#include "spawn_humans.dm"
#include "subsystem_init.dm"
#include "timer_sanity.dm"
#include "unit_test.dm"

// END_INCLUDE

#undef TEST_ASSERT
#undef TEST_ASSERT_EQUAL
#undef TEST_ASSERT_NOTEQUAL
#undef TEST_FOCUS
//#undef TEST_FOCUS - This define is used by vscode unit test extension to pick specific unit tests to run and appended later so needs to be used out of scope here
#endif
9 changes: 0 additions & 9 deletions code/modules/unit_tests/anchored_mobs.dm

This file was deleted.

2 changes: 1 addition & 1 deletion code/modules/unit_tests/bad_alcohol_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
if(istype(reagent, /datum/reagent/toxin)) // anything made from literal toxins is unsafe anyway, we don't care
any_ethanol=TRUE
if(!any_ethanol)
Fail("[D.result] is alcoholic but can be made with only non-alcoholic ingredients")
TEST_FAIL("[D.result] is alcoholic but can be made with only non-alcoholic ingredients")
7 changes: 0 additions & 7 deletions code/modules/unit_tests/card_mismatch.dm

This file was deleted.

61 changes: 0 additions & 61 deletions code/modules/unit_tests/chain_pull_through_space.dm

This file was deleted.

18 changes: 0 additions & 18 deletions code/modules/unit_tests/character_saving.dm

This file was deleted.

101 changes: 0 additions & 101 deletions code/modules/unit_tests/combat.dm

This file was deleted.

16 changes: 0 additions & 16 deletions code/modules/unit_tests/confusion.dm

This file was deleted.

File renamed without changes.
1 change: 0 additions & 1 deletion code/modules/unit_tests/elements/_elements.dm

This file was deleted.

25 changes: 0 additions & 25 deletions code/modules/unit_tests/emoting.dm

This file was deleted.

Loading

0 comments on commit 7483389

Please sign in to comment.