@@ -15,7 +15,6 @@ defmodule Exposure do
1515
1616 @ snapshot_directory Application . compile_env ( :exposure , :snapshot_directory , "_snapshots" )
1717 @ snapshot_test_tag Application . compile_env ( :exposure , :snapshot_test_tag , :snapshot )
18- @ test_paths Keyword . get ( Mix.Project . config ( ) , :test_paths , [ ] )
1918
2019 ################################
2120 # Public API
@@ -125,18 +124,31 @@ defmodule Exposure do
125124 end
126125
127126 defp test_paths do
128- :persistent_term . get ( { __MODULE__ , :test_paths } )
127+ key = { __MODULE__ , Mix.Project . get! ( ) , :test_paths }
128+
129+ case fetch_test_paths ( key ) do
130+ { :ok , paths } -> paths
131+ :error -> put_test_paths ( key )
132+ end
133+ end
134+
135+ defp fetch_test_paths ( key ) do
136+ { :ok , :persistent_term . get ( key ) }
129137 rescue
130- ArgumentError ->
131- paths =
132- @ test_paths
133- |> maybe_add_default_path ( )
134- |> Enum . map ( & Path . expand / 1 )
135- |> Enum . sort ( )
136- |> Enum . reduce ( [ ] , & maybe_add_test_path / 2 )
137-
138- :persistent_term . put ( { __MODULE__ , :test_paths } , paths )
139- paths
138+ ArgumentError -> :error
139+ end
140+
141+ defp put_test_paths ( key ) do
142+ paths =
143+ Mix.Project . config ( )
144+ |> Keyword . get ( :test_paths , [ ] )
145+ |> maybe_add_default_path ( )
146+ |> Enum . map ( & Path . expand / 1 )
147+ |> Enum . sort ( )
148+ |> Enum . reduce ( [ ] , & maybe_add_test_path / 2 )
149+
150+ :persistent_term . put ( key , paths )
151+ paths
140152 end
141153
142154 defp maybe_add_default_path ( [ ] ) do
0 commit comments