@@ -13,6 +13,7 @@ defmodule Sentry.Mixfile do
1313 package: package ( ) ,
1414 deps: deps ( ) ,
1515 elixirc_paths: elixirc_paths ( Mix . env ( ) ) ,
16+ test_paths: test_paths ( System . get_env ( "SENTRY_INTEGRATION" ) ) ,
1617 dialyzer: [
1718 flags: [ :unmatched_returns , :error_handling , :extra_return ] ,
1819 plt_file: { :no_warn , "plts/dialyzer.plt" } ,
@@ -22,7 +23,8 @@ defmodule Sentry.Mixfile do
2223 ] ,
2324 test_coverage: [ tool: ExCoveralls ] ,
2425 preferred_cli_env: [
25- "coveralls.html": :test
26+ "coveralls.html": :test ,
27+ "test.integrations": :test
2628 ] ,
2729 name: "Sentry" ,
2830 docs: [
@@ -83,6 +85,9 @@ defmodule Sentry.Mixfile do
8385 defp elixirc_paths ( :test ) , do: [ "test/support" ] ++ elixirc_paths ( :dev )
8486 defp elixirc_paths ( _other ) , do: [ "lib" ]
8587
88+ defp test_paths ( nil ) , do: [ "test" ]
89+ defp test_paths ( integration ) , do: [ "test_integrations/#{ integration } /test" ]
90+
8691 defp deps do
8792 [
8893 { :nimble_options , "~> 1.0" } ,
@@ -123,6 +128,62 @@ defmodule Sentry.Mixfile do
123128 end
124129
125130 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+ )
127188 end
128189end
0 commit comments