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

Version adapter and test fixes #186

Merged
merged 8 commits into from
Jul 22, 2024

Conversation

steven11sjf
Copy link
Contributor

@steven11sjf steven11sjf commented Jul 20, 2024

Fixes #30
Fixes #184

Added an adapter that converts a standard version field (Int16ul major, Int8 minor, Int8 patch) to a tuple or string "M.m.p" and optionally validates it against an expected version. This is applied to all places where a version field exists.

Fixed a bug where standard_format.game_model ignores the provided name and version field passed to it. Additionally, standard_format.create uses the new VersionAdapter.

Added parse/build for Dread .BMDEFS using a standard_format

Added a function to dread_data and samus_returns_data to return all files with a specified file extension. Replaces a large amount of code in test parametrization

Fixed some tests that were only testing on a subset of files (Bmssd, Bmbls, Bctex)

Fixed BCTEX skipping textures in packages

Removed test_lib functions that operate only on romfs files, since using the FileTreeEditor will cover these files and any in the packages

Added/simplified some checks to skip missing files

steven11sjf and others added 5 commits July 20, 2024 10:52
- new adapter added to common_types that can read a version number, and
  optionally validate it against an integer, string or tuple(int, int,
  int)
- applied this to all formats using version strings
- fixed a bug where standard_format.game_model would ignore the name and
  version passed to it
- fixed a bug where the bmssd tests wouldn't run
- added parse/build of dread .bmdefs (standard format)
- added functions to dread_data and samus_returns_data to get a list of
  all files ending in an extension
- applied this change to all tests that were using list comp to do this
  already
- fixed some tests that were only testing a subset of the total files
- removed test_lib functions that operate on only files, since the
  FileTreeEditor can handle these
- added  a parse_build_compare_editor_parsed function that compares a
  parsed file to its rebuilt and reparsed contents
- added/simplified some checks to skip missing files
Copy link

codecov bot commented Jul 20, 2024

Codecov Report

Attention: Patch coverage is 87.83784% with 9 lines in your changes missing coverage. Please review.

Project coverage is 75.11%. Comparing base (6c0e327) to head (d0e1b68).

Files Patch % Lines
src/mercury_engine_data_structures/common_types.py 88.88% 2 Missing ⚠️
src/mercury_engine_data_structures/dread_data.py 83.33% 1 Missing ⚠️
...rc/mercury_engine_data_structures/formats/bldef.py 0.00% 1 Missing ⚠️
src/mercury_engine_data_structures/formats/brem.py 0.00% 1 Missing ⚠️
src/mercury_engine_data_structures/formats/bres.py 0.00% 1 Missing ⚠️
src/mercury_engine_data_structures/formats/brev.py 0.00% 1 Missing ⚠️
src/mercury_engine_data_structures/formats/brsa.py 0.00% 1 Missing ⚠️
...rcury_engine_data_structures/samus_returns_data.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #186      +/-   ##
==========================================
+ Coverage   74.70%   75.11%   +0.41%     
==========================================
  Files          66       66              
  Lines        3277     3311      +34     
==========================================
+ Hits         2448     2487      +39     
+ Misses        829      824       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -30,8 +31,11 @@
def surface_bmsld(samus_returns_tree) -> Bmsld:
return samus_returns_tree.get_parsed_asset(all_bmsld[0], type_hint=Bmsld)

@pytest.mark.parametrize("bmsld_path", all_bmsld)
@pytest.mark.parametrize("bmsld_path", samus_returns_data.all_files_ending_with(".bmsld"))
Copy link
Member

Choose a reason for hiding this comment

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

Delete all_bmsld then

)
@pytest.mark.parametrize("pkg_path", dread_data.all_files_ending_with(".pkg"))
def test_compare_dread(dread_file_tree, pkg_path):
parse_build_compare_editor(Pkg, dread_file_tree, pkg_path)
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather the Pkg tests not use the FileTreeEditor, because that one uses Pkg a lot internally

Copy link
Member

@henriquegemignani henriquegemignani left a comment

Choose a reason for hiding this comment

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

There's a lot more of tests that automatically skip for missing files. Is there a way to know which of the file names we expect to be missing from the romfs? Because I'd prefer to fail a test if the file happens to be missing.

@steven11sjf
Copy link
Contributor Author

I can add lists of missing files to check against, will take a minute though

- files are now checked against a list of files expected to be missing
  before a test is skipped
- removed a duplicate bmmap test and changed test_minimap.py to
  test_bmmdef.py
- test_pkg retains old behavior of not using FileTreeEditor
)
@pytest.mark.parametrize("bmssd_path", samus_returns_data.all_files_ending_with(".bmssd"))
def test_compare_msr(samus_returns_tree, bmssd_path):
if bmssd_path in sr_missing:
Copy link
Member

Choose a reason for hiding this comment

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

Can you exclude the path from the parametrize, instead of skipping the test? Should make it cleaner overall with less skipped tests, plus be faster.

- added an optional list[str] arg "exclusions" to
  all_files_ending_with
- parametrized test args now use this field to exclude missing files
  from parametrization, resulting in no skipped tests
@henriquegemignani henriquegemignani added this pull request to the merge queue Jul 22, 2024
Merged via the queue into randovania:main with commit 600aeed Jul 22, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add method for all files with an extension Tests skipped for missing files
2 participants