Skip to content

Commit

Permalink
Ensures that all Unit Tests are ticked in _unit_tests.dm (#76404) (…
Browse files Browse the repository at this point in the history
…#22176)

* Ensures that all Unit Tests are ticked in `_unit_tests.dm` (#76404)

## About The Pull Request

Ensures we don't get a repeat of #76345 (unit test that wasn't ticked in
the `_unit_tests.dm` file, fixed in
596ca8b6d4cc49cd69fc104b53b7f4973497a2e5). Basically, we leverage the
code that was already being used in the DME Validator but then expand it
a bunch via using JSON Schemas that correspond to the type of scan we
want to run. Even though sorting unit tests alphabetically is a bit
different than sorting the tgstation DME, it's good to leverage the
already existing framework rather than create a copy-pasta "lesser" code
runner. This went through strenous testing on my end, so let me know if
anything seems off.

While in the area, I added some other niceties that I've found work
really well in GitHub Runners environments, as well as local testing in
case you really like doing that before you make a PR for some reason.
## Why It's Good For The Game

![image](https://github.com/tgstation/tgstation/assets/34697715/307161d7-cef1-418b-9a51-2a7bf6c5b678)

This is what it looks like pre-596ca8b6d4cc49cd69fc104b53b7f4973497a2e5
(this is now merged, so it will pass CI)

De-hardcodes some stuff and allows for some neater flexibility, less
cringe unit tests being coded and not being ticked in the file, etc.
etc.
## Changelog
Nothing for players to care about.

Let me know if you have a better idea than the schemas, I couldn't think
of one that could be really extensible and flexible in the same way this
is.
# Conflicts:
#	code/modules/unit_tests/_unit_tests.dm
#	tools/validate_dme.py

* Modular tick enforcement

* Update tgstation_dme.json

* Update tgstation_dme.json

* Update tgstation.dme

* Update unit_tests.json

* Modular tick enforcement

* oop

* Update ticked_file_enforcement.py

I cannot python what the heck

* Update ticked_file_enforcement.py

* Update ticked_file_enforcement.py

* Update ticked_file_enforcement.py

* Update ticked_file_enforcement.py

ugh

* Update ticked_file_enforcement.py

* You have got to be kidding me.....

* Update _unit_tests.dm

* Update _unit_tests.dm

* Update _unit_tests.dm

* Update unit_tests.json

* Update unit_tests.json

* Update _unit_tests.dm

* Update unit_tests.json

* Update _unit_tests.dm

* Update _unit_tests.dm

* Update

* Update unit_tests.json

* Update ci_suite.yml

* Update ci_suite.yml

* Update ci_suite.yml

* Update _unit_tests.dm

* Update

* Ughdate

* Ughdate

* Ughdate

* Debug time

* Update ticked_file_enforcement.py

* Update _unit_tests.dm

* Update tgstation.dme

* Revert "Update tgstation.dme"

This reverts commit 4e82ad6b0be937d26ac36884f2d00d6718d72029.

* Update _unit_tests.dm

* What

* Hmm

* Update unit_tests.json

* Ugh

* Update ticked_file_enforcement.py

* This is so jank

* hnnng

* Update ticked_file_enforcement.py

* what. do. you. want.

* Update ticked_file_enforcement.py

* Now let's see if it works

* Revert "Now let's see if it works"

This reverts commit 915c40d99da8b7a869db1205e48e4f7178da9b8e.

---------

Co-authored-by: san7890 <[email protected]>
Co-authored-by: GoldenAlpharex <[email protected]>
Co-authored-by: Bloop <[email protected]>
  • Loading branch information
4 people authored and Iajret committed Aug 25, 2023
1 parent e8bee2f commit 19ea7ba
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
bash tools/ci/check_filedirs.sh tgstation.dme
bash tools/ci/check_changelogs.sh
bash tools/ci/check_grep.sh
tools/bootstrap/python tools/ticked_file_enforcement/ticked_file_enforcement.py < tools/ticked_file_enforcement/schemas/tgstation_dme.json
tools/bootstrap/python tools/ticked_file_enforcement/ticked_file_enforcement.py < tools/ticked_file_enforcement/schemas/unit_tests.json
tools/bootstrap/python tools/ticked_file_enforcement/ticked_file_enforcement.py < tools/ticked_file_enforcement/schemas/modular_skyrat.json # SKYRAT EDIT ADDITION - modular tick enforcement
bash skyrat/tools/skyrat_check_grep.sh # SKYRAT EDIT ADDITION - checking modular_skyrat code
bash fluffy/tools/fluffy_check_grep.sh # FLUFFY EDIT ADDITION - checking tff_modular code
bash tools/ci/check_misc.sh
Expand Down
13 changes: 7 additions & 6 deletions code/modules/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@
#define TRAIT_SOURCE_UNIT_TESTS "unit_tests"

// BEGIN_INCLUDE
// SKYRAT EDIT START
#include "~skyrat/opposing_force.dm"
#include "~skyrat/automapper.dm"
//SKYRAT EDIT END
#include "abductor_baton_spell.dm"
#include "ablative_hud.dm"
#include "achievements.dm"
Expand Down Expand Up @@ -192,8 +188,8 @@
#include "objectives.dm"
#include "operating_table.dm"
#include "orderable_items.dm"
#include "organs.dm"
#include "organ_set_bonus.dm"
#include "organs.dm"
#include "outfit_sanity.dm"
#include "paintings.dm"
#include "pills.dm"
Expand Down Expand Up @@ -222,8 +218,8 @@
#include "screenshot_humanoids.dm"
#include "screenshot_husk.dm"
#include "screenshot_saturnx.dm"
#include "security_officer_distribution.dm"
#include "security_levels.dm"
#include "security_officer_distribution.dm"
#include "serving_tray.dm"
#include "simple_animal_freeze.dm"
#include "siunit.dm"
Expand Down Expand Up @@ -266,6 +262,11 @@
#include "verify_emoji_names.dm"
#include "wizard_loadout.dm"
#include "worn_icons.dm"
// SKYRAT EDIT START
#include "~skyrat\automapper.dm"
#include "~skyrat\opposing_force.dm"
// SKYRAT EDIT END
// END_INCLUDE
#ifdef REFERENCE_TRACKING_DEBUG //Don't try and parse this file if ref tracking isn't turned on. IE: don't parse ref tracking please mr linter
#include "find_reference_sanity.dm"
#endif
Expand Down
2 changes: 1 addition & 1 deletion tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5649,13 +5649,13 @@
#include "interface\interface.dm"
#include "interface\menu.dm"
#include "interface\stylesheet.dm"
#include "interface\skin.dmf"
#include "interface\fonts\fonts_datum.dm"
#include "interface\fonts\grand_9k.dm"
#include "interface\fonts\pixellari.dm"
#include "interface\fonts\spess_font.dm"
#include "interface\fonts\tiny_unicode.dm"
#include "interface\fonts\vcr_osd_mono.dm"
#include "interface\skin.dmf"
#include "modular_skyrat\master_files\code\_globalvars\configuration.dm"
#include "modular_skyrat\master_files\code\_globalvars\religion.dm"
#include "modular_skyrat\master_files\code\_globalvars\lists\ambience.dm"
Expand Down
7 changes: 7 additions & 0 deletions tools/ticked_file_enforcement/schemas/modular_skyrat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"file": "tgstation.dme",
"scannable_directory": "modular_skyrat/",
"subdirectories": true,
"excluded_files": [],
"forbidden_includes": []
}
3 changes: 2 additions & 1 deletion tools/ticked_file_enforcement/schemas/tgstation_dme.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"excluded_files": [],
"forbidden_includes": [
"code/modules/tgs/**/*.dm",
"code/modules/unit_tests/[!_]*.dm"
"code/modules/unit_tests/[!_]*.dm",
"code/modules/unit_tests/~skyrat/[!_]*.dm"
]
}
10 changes: 10 additions & 0 deletions tools/ticked_file_enforcement/ticked_file_enforcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def post_error(string):
break
elif not reading:
continue
# SKYRAT EDIT START - Modular unit tests
elif line == "// SKYRAT EDIT START":
continue
elif line == "// SKYRAT EDIT END":
continue
# SKYRAT EDIT END

lines.append(line)

Expand All @@ -78,6 +84,10 @@ def post_error(string):
dm_path = code_file.replace('/', '\\')
else:
dm_path = os.path.basename(code_file)
# SKYRAT EDIT START - Modular unit tests - have to append this again after it gets removed; this was not designed upstream with subfolders for unit tests in mind so we must cope.
if("~skyrat/" in code_file):
dm_path = "~skyrat\\" + dm_path
# SKYRAT EDIT END

included = f"#include \"{dm_path}\"" in lines

Expand Down

0 comments on commit 19ea7ba

Please sign in to comment.