@@ -13,6 +13,7 @@ defmodule Sentry.Mixfile do
13
13
package: package ( ) ,
14
14
deps: deps ( ) ,
15
15
elixirc_paths: elixirc_paths ( Mix . env ( ) ) ,
16
+ test_paths: test_paths ( System . get_env ( "SENTRY_INTEGRATION" ) ) ,
16
17
dialyzer: [
17
18
flags: [ :unmatched_returns , :error_handling , :extra_return ] ,
18
19
plt_file: { :no_warn , "plts/dialyzer.plt" } ,
@@ -22,7 +23,8 @@ defmodule Sentry.Mixfile do
22
23
] ,
23
24
test_coverage: [ tool: ExCoveralls ] ,
24
25
preferred_cli_env: [
25
- "coveralls.html": :test
26
+ "coveralls.html": :test ,
27
+ "test.integrations": :test
26
28
] ,
27
29
name: "Sentry" ,
28
30
docs: [
@@ -83,6 +85,9 @@ defmodule Sentry.Mixfile do
83
85
defp elixirc_paths ( :test ) , do: [ "test/support" ] ++ elixirc_paths ( :dev )
84
86
defp elixirc_paths ( _other ) , do: [ "lib" ]
85
87
88
+ defp test_paths ( nil ) , do: [ "test" ]
89
+ defp test_paths ( integration ) , do: [ "test_integrations/#{ integration } /test" ]
90
+
86
91
defp deps do
87
92
[
88
93
{ :nimble_options , "~> 1.0" } ,
@@ -123,6 +128,62 @@ defmodule Sentry.Mixfile do
123
128
end
124
129
125
130
defp aliases do
126
- [ test: [ "sentry.package_source_code" , "test" ] ]
131
+ [
132
+ test: [ "sentry.package_source_code" , "test" ] ,
133
+ "test.integrations": & run_integration_tests_if_supported / 1
134
+ ]
135
+ end
136
+
137
+ defp run_integration_tests_if_supported ( args ) do
138
+ if Version . match? ( System . version ( ) , ">= 1.16.0" ) do
139
+ run_integration_tests ( "phoenix_app" , args )
140
+ else
141
+ Mix . shell ( ) . info ( "Skipping integration tests for Elixir versions < 1.16" )
142
+ end
143
+ end
144
+
145
+ defp run_integration_tests ( integration , args ) do
146
+ IO . puts (
147
+ IO.ANSI . format ( [
148
+ "\n " ,
149
+ [ :bright , :cyan , "==> Running tests for integration: #{ integration } " ]
150
+ ] )
151
+ )
152
+
153
+ case setup_integration ( integration ) do
154
+ { _ , 0 } ->
155
+ color_arg = if IO.ANSI . enabled? ( ) , do: "--color" , else: "--no-color"
156
+
157
+ { _ , status } = run_in_integration ( integration , [ "test" , color_arg | args ] )
158
+
159
+ if status > 0 do
160
+ IO . puts (
161
+ IO.ANSI . format ( [
162
+ :red ,
163
+ "Integration tests for #{ integration } failed"
164
+ ] )
165
+ )
166
+
167
+ System . at_exit ( fn _ -> exit ( { :shutdown , 1 } ) end )
168
+ else
169
+ IO . puts (
170
+ IO.ANSI . format ( [
171
+ :green ,
172
+ "Integration tests for #{ integration } passed"
173
+ ] )
174
+ )
175
+ end
176
+ end
177
+ end
178
+
179
+ defp setup_integration ( integration ) do
180
+ run_in_integration ( integration , [ "deps.get" ] )
181
+ end
182
+
183
+ defp run_in_integration ( integration , args ) do
184
+ System . cmd ( "mix" , args ,
185
+ into: IO . binstream ( :stdio , :line ) ,
186
+ cd: Path . join ( "test_integrations" , integration )
187
+ )
127
188
end
128
189
end
0 commit comments