Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Testening: Ports improved unit tests from TG, New mapping tests, Refactors of existing tests to improve code quality #11364

Merged
merged 268 commits into from
Sep 8, 2024

Conversation

PowerfulBacon
Copy link
Member

@PowerfulBacon PowerfulBacon commented Aug 24, 2024

About The Pull Request

Ports the following PRs in whole, or in part (There's a lot, I apologise if I missed any PRs but I included the authors as commit co-authors where I could find them):

Ports the following files (Authors have been credited):
https://github.com/tgstation/tgstation/commits/master/code/controllers/subsystem/garbage.dm
https://github.com/tgstation/tgstation/commits/master/code/__DEFINES/qdel.dm
https://github.com/tgstation/tgstation/blob/776ecd60600c43d56be173a9f10505425d2c07bc/code/__DEFINES/_helpers.dm#L29
https://github.com/tgstation/tgstation/blob/776ecd60600c43d56be173a9f10505425d2c07bc/code/datums/datum.dm#L75
tgstation/tgstation@225562b

Ports the better unit testing system that TG has.

Makes improvements to the create and delete tests by adding in defines which can be used modularly.

Ports some improvements and fixes to QDEL from TGstation (excluding some content which is 515 exclusive)

Non-Goals

  • Does not activate the create and destroy test. That can come in the future when I can be bothered to fix the mountain of hard-dels that we probably have.
  • Does not add any screenshot tests, despite porting the framework.
  • Does not add any auto-cut icons, despite porting the framework.

JukeBuild Updates

  • Updates JukeBuild to the latest version.
  • This adds icon cutter support, however it doesn't use either of them yet since that requires additional configuration to setup.
  • On top of that, this implements support fot compiling on 514, as the latest jukebuild doesn't allow for 515 compilation.

Annotations

Any errors identified will be annotated inside of Github, click on a commit to see the errors being flagged.

image

Linter Expansion

Maplint

Maplint adds a simple way to check turfs for typepath based mapping related issues. This operates on the mapfile itself and isn't capable of more advanced logic, but it can catch simple things such as duplicate objects, or invalid var-edits. For more advanced map checks, I have added in a new category of unit tests; map tests.

The following tests will start disabled and will become enabled later:

  • Require directional APCs (Too much work for this PR)
  • Smart cable checker (We don't use smart cables)
  • Require directional posters (Too much work for this PR)
  • Require direction telescreens (Too much work for this PR)
  • Require directional windows (Too much work for this PR)

OpenDream Linting

We now run the code against OpenDream, which will pick up some additional mistakes that Byond skips over.

Tab/Space Indentation

Ports the lint for tab vs space indentation. This lint was very flakey and was updated to allow spaces before a * symbol (as seen in block comments), however I still fixed all the issues that it brought up. A lot of these ended up being non-issues and resulted in a large number of diffs.

Test Expansion

Map Test Expansion

This adds a new abstract unit test type, map_test. This allows for you to do the following things:

  • Check a turf against some custom criteria
  • Check an area against some criteria
  • Compile specific targets to check
  • Check those specific targets
  • Check a z-level for validity
  • Check a map for validity

This offers quite a lot of extensibility and can do things that maplint is incapable of, such as determining if something is valid relative to the surrounding tiles. It is currently used for the following things:

  • Validating area power requirements
  • Ensuring no duplicate items on a turf (Fully comprehensive unlike the maplint variant, but can't handle decals)
  • Ensuring that disposals are valid and the sorting tubes are placed correctly
  • Ensuring that lights and cameras are attached to a wall correctly
  • Ensuring that no active turfs exist at roundstart

CreateAndDestroy Code Cleanup

Modularises the create and destoy code, instead of using a global list for the exclude variables a define has been added which excludes a type, or its subtypes. This has been applied to everything that requires multiple parameters in Initialize, under the assumption that if you need to pass something in, then it isn't something you can just new() safely. This is partly why this PR is so huge.

ScreenShot Tests

Adds support for screenshot tests, as seen on TG. This PR doesn't implement any screenshot tests however. We could likely use this framework to have automatic generation of rooms for PRs that resprite items.

Why It's Good For The Game

We can now run tests against maps, which is incredibly useful because maps often get errors. As a side effect, the mapping checks are strict but making them testable prevents avoidable errors, even if it is a bit annoying to update initially.

Testing Photographs and Procedure

Everything I am changing here has unit tests and are mistakes already, making this PR a little bit easier to go through.

Testing the tests

See the output at the bottom of this PR.

Testing random maints changes

image

image

Other

image

image

image

image

image

image

image

image

image

image

image

Changelog

🆑 PowerfulBacon, BriggsIDP, san7890, LemonInTheDark, MrStonedOne, Mothblocks, Cyberboss, Tastyfish, ZephyrTFA, Andrew, tattle, Jolly, die_amond, Tim, optimumtact, Y0SH1M4S73R, StyleMistake, other /TG/station contributors
fix: Adds in some map checker unit tests, which check disposal networks for correct sorting.
fix: Random maints will clean up directional wall items after spawning them if they were unable to be placed on a wall.
server: Improves unit testing
tweak: Changed disposal pipe sorting logic slightly. Entering a sorting pipe backwards will continue backwards, entering a pipe from the sort direction will send you forwards. Entering from the correct direction will continue to sort.
add: Adds a new disposal pipe for filtering unsorted items that need sorting.
fix: Packages will now always arrive in their destination, no matter where on the network they are entered.
tweak: Fridges are no longer placed in walls
tweak: All areas must have APCs, unless they are unpowered.
/:cl:

@PowerfulBacon
Copy link
Member Author

I have no idea why this is seg-faulting

Copy link
Member

@Crossedfall Crossedfall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some relatively small things. The python scripts aren't the best in terms of formatting and readability, but if they work I wont spend a lot of time trying to fix it (minus the two I started on)

.github/alternate_byond_versions.txt Outdated Show resolved Hide resolved
key: ${{ runner.os }}-spacemandmm-${{ hashFiles('dependencies.sh') }}
restore-keys: |
${{ runner.os }}-spacemandmm-
- name: Restore Yarn cache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be a worse alternative to our current caching.. But it's a bit hard to tell without the checking being actively ran. This should be reviewed after this PR has been merged and checks have been running for a little while.

tools/UpdatePaths/__main__.py Outdated Show resolved Hide resolved
tools/UpdatePaths/__main__.py Outdated Show resolved Hide resolved
@Crossedfall Crossedfall added this pull request to the merge queue Sep 8, 2024
Merged via the queue into BeeStation:master with commit 7640e0c Sep 8, 2024
23 checks passed
@Dejaku51 Dejaku51 mentioned this pull request Sep 23, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants