snake-biscuits / bsp_tool

Python library for analysing .bsp files
GNU General Public License v3.0
104 stars 8 forks source link

Test every ArchiveClass #194

Open snake-biscuits opened 2 months ago

snake-biscuits commented 2 months ago

As stated in #191 we should be testing all ArchiveClasses as they're being actively worked on

ArchiveClasses

Related

snake-biscuits commented 2 months ago

atm we're only testing __init__s (specifically .from_file()) some of these tests include .namelist() & .read() checks

.namelist() can't work without some __init__ .read() can't work without .namelist() loading a file 3 times to test 2 methods is a bit much but it'd still be best to break these tests up

loading the maps before tests is less than ideal

snake-biscuits commented 2 months ago

excluding nexon.PakFile because it only appears in CS:O2 .bsps

We need some specific SpecialLumpClass tests for this But afaik no public source tool for making these PakFiles exists

organnerx has some people making tools, idk how public they are

Which means the only real-world examples of the format we're going to find are inside maps Tho we can test .from_bytes() like we do for pkware.Zip

For testing the real-world cases:

snake-biscuits commented 2 months ago

nexon.PakFile.as_bytes() is really important to test, since it's required for NexonBsp.save_as()

snake-biscuits commented 2 months ago

ArchiveClasses don't have to have .as_bytes() methods Except for pkware.Zip & nexon.PakFile, since they both get used as SpecialLumpClasses

But we should keep links etc. for external tools used with each format in docs/ Something to add to the DB

snake-biscuits commented 2 months ago

Testing nexon.PakFile via CS:O2 .bsps is failing in a really wierd way

>>> import bsp_tool
>>> bsp = bsp_tool.load_bsp("E:/Mod/CSO2/maps/gb_varena.bsp")  # map with least files in pakfile (8)
>>> bsp.headers["PAKFILE"]
<LumpHeader (offset: 587596, length: 134135, version: 0, compressed: 0, fourCC: 0)>
>>> len(bsp.PAKFILE.as_bytes())
134146  # 11 bytes over???

Really need to be testing this w/ a handmade deflate for .from_bytes() And as a SpecialLumpClass, though that requires either local test maps:

Or a specific test that targets MegaTest maps: