@@ -64,6 +64,57 @@ defmodule Sentry.SourcesTest do
6464 To fix this, you'll have to rename one of the conflicting paths.
6565 """
6666 end
67+
68+ test "accepts string patterns for source_code_exclude_patterns (OTP 28+ compatibility)" do
69+ paths = [
70+ File . cwd! ( ) <> "/test/fixtures/example-umbrella-app/apps/app_a" ,
71+ File . cwd! ( ) <> "/test/fixtures/example-umbrella-app/apps/app_b"
72+ ]
73+
74+ assert { :ok , result } =
75+ Sources . load_files (
76+ root_source_code_paths: paths ,
77+ source_code_exclude_patterns: [ "module_b" ]
78+ )
79+
80+ assert Map . has_key? ( result , "lib/module_a.ex" )
81+ refute Map . has_key? ( result , "lib/module_b.ex" )
82+ end
83+
84+ test "accepts mixed string and regex patterns for source_code_exclude_patterns" do
85+ paths = [
86+ File . cwd! ( ) <> "/test/fixtures/example-umbrella-app/apps/app_a" ,
87+ File . cwd! ( ) <> "/test/fixtures/example-umbrella-app/apps/app_b"
88+ ]
89+
90+ assert { :ok , result } =
91+ Sources . load_files (
92+ root_source_code_paths: paths ,
93+ source_code_exclude_patterns: [ ~r/ module_a/ , "module_b" ]
94+ )
95+
96+ refute Map . has_key? ( result , "lib/module_a.ex" )
97+ refute Map . has_key? ( result , "lib/module_b.ex" )
98+ end
99+
100+ test "string patterns survive term serialization (OTP 28+ release simulation)" do
101+ paths = [
102+ File . cwd! ( ) <> "/test/fixtures/example-umbrella-app/apps/app_a" ,
103+ File . cwd! ( ) <> "/test/fixtures/example-umbrella-app/apps/app_b"
104+ ]
105+
106+ original_config = [
107+ root_source_code_paths: paths ,
108+ source_code_exclude_patterns: [ "module_b" , "/deps/" ]
109+ ]
110+
111+ serialized = :erlang . term_to_binary ( original_config )
112+ deserialized_config = :erlang . binary_to_term ( serialized )
113+
114+ assert { :ok , result } = Sources . load_files ( deserialized_config )
115+ assert Map . has_key? ( result , "lib/module_a.ex" )
116+ refute Map . has_key? ( result , "lib/module_b.ex" )
117+ end
67118 end
68119
69120 describe "load_source_code_map_if_present/0" do
0 commit comments