@@ -30,6 +30,35 @@ def test_source_details_and_exact_lookup(self):
3030 self .assertEqual (row ['uuid' ],detail ['uuid' ])
3131 self .assertTrue (detail ['data' ])
3232
33+ def test_mupdf_case_distinct_names_and_detail_paths (self ):
34+ for name ,id ,legacy_path ,alias in [('libMuPDF.so' ,1773 ,'native-libs/regex/mupdf_uppercase.json' ,'mupdf_uppercase' ),
35+ ('libmupdf.so' ,3090 ,'native-libs/libmupdf.so.json' ,None )]:
36+ row = next (row for row in self .rows if row ['id' ]== id )
37+ self .assertFalse (row ['isRegexRule' ])
38+ self .assertEqual (alias ,row ['regexName' ])
39+ for use_regex in (False ,True ):
40+ self .assertEqual (id ,rules .find_rule (self .rows ,name ,0 ,use_regex ))
41+ self .assertEqual (self .common [row ['detailPath' ]],self .legacy [legacy_path ])
42+ self .assertNotIn ('native-libs/libMuPDF.so.json' ,self .legacy )
43+
44+ def test_legacy_paths_reject_case_collisions_and_allow_identical_reuse (self ):
45+ with tempfile .TemporaryDirectory () as tmp :
46+ root = Path (tmp );shutil .copytree (ROOT / 'icons' ,root / 'icons' );(root / 'libraries' ).mkdir ()
47+ filename = 'D100E2DE-D729-4D97-A66E-8B51A090ED5B.json'
48+ original = rules .read (ROOT / 'libraries' / filename );path = root / 'libraries' / filename
49+ for source in ('matcher' ,'orphan' ):
50+ with self .subTest (source = source ):
51+ lib = copy .deepcopy (original )
52+ if source == 'matcher' :lib ['matchers' ][0 ]['legacyPath' ]= 'native-libs/libMuPDF.so.json'
53+ else :lib ['unreferencedDescriptions' ]= [dict (path = 'native-libs/libMuPDF.so.json' ,payload = dict (uuid = lib ['uuid' ],data = lib ['data' ]))]
54+ path .write_bytes (rules .encoded (lib ))
55+ with self .assertRaisesRegex (ValueError ,'Case-insensitive legacy path collision' ):rules .load_source (root )
56+ lib = copy .deepcopy (original )
57+ lib ['unreferencedDescriptions' ]= [dict (path = lib ['matchers' ][0 ]['legacyPath' ],payload = dict (uuid = lib ['uuid' ],data = lib ['data' ]))]
58+ path .write_bytes (rules .encoded (lib ))
59+ _ ,_ ,legacy ,_ = rules .load_source (root )
60+ self .assertEqual (2 ,len (legacy ))
61+
3362 def test_reproducible_build_and_versioning (self ):
3463 with tempfile .TemporaryDirectory () as tmp ,contextlib .redirect_stdout (io .StringIO ()):
3564 a ,b = Path (tmp )/ 'a' ,Path (tmp )/ 'b'
0 commit comments