@@ -176,11 +176,11 @@ def _process_and_assert_configuration_changes(
176176 expected_new_code_mappings
177177 )
178178 for expected_cm in expected_new_code_mappings :
179- code_mapping = current_code_mappings .filter (
180- stack_root = expected_cm ["stack_root" ],
181- source_root = expected_cm ["source_root" ],
182- ).first ()
179+ code_mapping = current_code_mappings .get (
180+ project_id = self .project .id , stack_root = expected_cm ["stack_root" ]
181+ )
183182 assert code_mapping is not None
183+ assert code_mapping .source_root == expected_cm ["source_root" ]
184184 assert code_mapping .repository .name == expected_cm ["repo_name" ]
185185 else :
186186 assert current_code_mappings .count () == starting_code_mappings_count
@@ -1003,3 +1003,64 @@ def test_categorized_frames_are_not_processed(self) -> None:
10031003 expected_new_code_mappings = [self .code_mapping ("android/app/" , "src/android/app/" )],
10041004 expected_new_in_app_stack_trace_rules = ["stack.module:android.app.** +app" ],
10051005 )
1006+
1007+ def test_multi_module_with_old_granularity (self ) -> None :
1008+ java_module_prefix = "com.example.multi"
1009+ module_prefix = java_module_prefix .replace ("." , "/" ) + "/"
1010+ repo_trees = {
1011+ REPO1 : [
1012+ f"modules/modX/{ module_prefix } foo/Bar.kt" ,
1013+ f"modules/modY/{ module_prefix } bar/Baz.kt" ,
1014+ ]
1015+ }
1016+ frames = [
1017+ self .frame_from_module (f"{ java_module_prefix } .foo.Bar" , "Bar.kt" ),
1018+ self .frame_from_module (f"{ java_module_prefix } .bar.Baz" , "Baz.kt" ),
1019+ ]
1020+ self ._process_and_assert_configuration_changes (
1021+ repo_trees = repo_trees ,
1022+ frames = frames ,
1023+ platform = self .platform ,
1024+ expected_new_code_mappings = [
1025+ # It's missing the extra granularity
1026+ # It's going to pick modY since it is the first frame processed, thus,
1027+ # the other frame will not have a working code mapping
1028+ self .code_mapping ("com/example/multi/" , "modules/modY/com/example/multi/" )
1029+ ],
1030+ expected_new_in_app_stack_trace_rules = ["stack.module:com.example.** +app" ],
1031+ )
1032+
1033+ def test_multi_module (self ) -> None :
1034+ # Some Java projects have all modules under the same com/foo/bar directory
1035+ # however, some projects have different modules under different directories
1036+ # Case 1:
1037+ # com.example.multi.foo -> modules/com/example/multi/foo/Bar.kt
1038+ # com.example.multi.bar -> modules/com/example/multi/bar/Baz.kt
1039+ # Case 2:
1040+ # com.example.multi.foo -> modules/modX/com/example/multi/foo/Bar.kt (Notice modX infix)
1041+ # com.example.multi.bar -> modules/modY/com/example/multi/bar/Baz.kt (Notice modY infix)
1042+ java_module_prefix = "com.example.multi"
1043+ module_prefix = java_module_prefix .replace ("." , "/" ) + "/"
1044+ repo_trees = {
1045+ REPO1 : [
1046+ f"modules/modX/{ module_prefix } foo/Bar.kt" ,
1047+ f"modules/modY/{ module_prefix } bar/Baz.kt" ,
1048+ ]
1049+ }
1050+ frames = [
1051+ self .frame_from_module (f"{ java_module_prefix } .foo.Bar" , "Bar.kt" ),
1052+ self .frame_from_module (f"{ java_module_prefix } .bar.Baz" , "Baz.kt" ),
1053+ ]
1054+ with self .options ({"auto_source_code_config.multi_module_java" : True }):
1055+ self ._process_and_assert_configuration_changes (
1056+ repo_trees = repo_trees ,
1057+ frames = frames ,
1058+ platform = self .platform ,
1059+ expected_new_code_mappings = [
1060+ self .code_mapping (f"{ module_prefix } foo/" , f"modules/modX/{ module_prefix } foo/" ),
1061+ self .code_mapping (f"{ module_prefix } bar/" , f"modules/modY/{ module_prefix } bar/" ),
1062+ ],
1063+ expected_new_in_app_stack_trace_rules = [
1064+ f"stack.module:{ java_module_prefix } .** +app"
1065+ ],
1066+ )
0 commit comments