@@ -16,7 +16,8 @@ def dict_raise_on_duplicates(ordered_pairs):
1616 return d
1717
1818
19- MODS_JSON = Path (__file__ ).parent .parent / "mod_polling" / "mods.json"
19+ REPO_ROOT = Path (__file__ ).parent .parent
20+ MODS_JSON = REPO_ROOT / "mod_polling" / "mods.json"
2021
2122LEGACY_CURSE_FILENAMES = (
2223 ("AdventOfAscension" , "AoA-Tslat-1.1.3.jar" , "Tslat-1.1.3" ),
@@ -30,7 +31,6 @@ def dict_raise_on_duplicates(ordered_pairs):
3031 ("CookingForBlockheads" , "CookingForBlockheads_1.12.2-6.5.0.jar" , "6.5.0" ),
3132 ("DeathCounter" , "DeathCounter-4.0.0.jar" , "4.0.0" ),
3233 ("DeathCounter" , "DeathCounter-1.12.2-1.1.0.jar" , "1.1.0" ),
33- ("Ding" , "Ding-MC1.7.10v2.jar" , "MC1.7.10v2" ),
3434 ("Ding" , "Ding-1.12.2-1.0.2.jar" , "1.0.2" ),
3535 ("ForgeMultipart" , "ForgeMultipart-1.12.2-2.6.2.83-universal.jar" , "2.6.2.83" ),
3636 ("HardcoreQuestingMode" , "HQM-The Journey-4.4.4.jar" , "4.4.4" ),
@@ -72,6 +72,13 @@ def dict_raise_on_duplicates(ordered_pairs):
7272 ("iChunUtil" , "iChunUtil-1.21.5-Fabric-1.0.7.jar" , "1.0.7" ),
7373)
7474
75+ # Filenames whose mod version is inseparable from the Minecraft version. A regex that matches these
76+ # yields a version containing "mc", which version_blocklist.yml rejects, aborting the whole mod's poll.
77+ UNPARSEABLE_CURSE_FILENAMES = (
78+ ("Ding" , "Ding-MC1.7.10v2.jar" ),
79+ ("Ding" , "Ding-MC1.9.0v2.jar" ),
80+ )
81+
7582
7683class TestModsJson :
7784 def setup_method (self ):
@@ -123,12 +130,27 @@ def test_neoforge_parser(self):
123130 ("mod" , "filename" , "expected_version" ),
124131 LEGACY_CURSE_FILENAMES + CURRENT_CURSE_FILENAMES ,
125132 )
126- def test_curse_filename_regressions (self , mod_poller , mod , filename , expected_version ):
133+ def test_curse_filename_regressions (self , mod_poller , monkeypatch , mod , filename , expected_version ):
127134 # Match through the poller's own compile/search path so flag or matching changes fail here too.
128135 mod_poller .mods [mod ] = self .mods [mod ]
129136 mod_poller .compile_regex (mod )
130137
138+ # Load the real blocklist so a regex cannot capture a version the poller would reject.
139+ monkeypatch .chdir (REPO_ROOT )
140+ mod_poller .load_version_blocklist ()
141+
131142 match = mod_poller .match_mod_regex (mod , filename )
132143
133144 assert match , f"{ mod } regex did not match { filename !r} "
134- assert match .group ("version" ) == expected_version
145+
146+ version = match .group ("version" )
147+
148+ assert version == expected_version
149+ assert mod_poller .is_version_valid (version ), f"{ mod } version { version !r} is rejected by version_blocklist.yml"
150+
151+ @pytest .mark .parametrize (("mod" , "filename" ), UNPARSEABLE_CURSE_FILENAMES )
152+ def test_curse_filenames_without_usable_version_are_not_matched (self , mod_poller , mod , filename ):
153+ mod_poller .mods [mod ] = self .mods [mod ]
154+ mod_poller .compile_regex (mod )
155+
156+ assert mod_poller .match_mod_regex (mod , filename ) is None
0 commit comments