infinity_test 1.0.3 → 2.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +31 -0
  3. data/.gitignore +3 -0
  4. data/.rspec +2 -2
  5. data/AI_INTEGRATION_IDEAS.md +203 -0
  6. data/Gemfile +3 -15
  7. data/HISTORY.md +84 -0
  8. data/History.markdown +82 -0
  9. data/{.infinity_test → INFINITY_TEST} +18 -15
  10. data/LICENSE.txt +2 -2
  11. data/README.md +867 -0
  12. data/Rakefile +1 -65
  13. data/TODO.markdown +38 -24
  14. data/bin/infinity_test +1 -4
  15. data/images/fuuu/pending.png +0 -0
  16. data/images/fuuu/success.png +0 -0
  17. data/infinity_test.gemspec +41 -189
  18. data/lib/infinity_test/core/auto_discover.rb +67 -0
  19. data/lib/infinity_test/core/base.rb +369 -0
  20. data/lib/infinity_test/core/callback.rb +59 -0
  21. data/lib/infinity_test/core/changed_file.rb +13 -0
  22. data/lib/infinity_test/core/command_builder.rb +48 -0
  23. data/lib/infinity_test/core/command_runner.rb +38 -0
  24. data/lib/infinity_test/core/configuration_merge.rb +37 -0
  25. data/lib/infinity_test/core/continuous_test_server.rb +124 -0
  26. data/lib/infinity_test/core/load_configuration.rb +48 -0
  27. data/lib/infinity_test/core/notifier.rb +59 -0
  28. data/lib/infinity_test/core/options.rb +134 -0
  29. data/lib/infinity_test/core/runner.rb +18 -0
  30. data/lib/infinity_test/core/version.rb +5 -0
  31. data/lib/infinity_test/framework/base.rb +93 -0
  32. data/lib/infinity_test/framework/django.rb +109 -0
  33. data/lib/infinity_test/framework/elixir_mix.rb +47 -0
  34. data/lib/infinity_test/framework/fast_api.rb +104 -0
  35. data/lib/infinity_test/framework/padrino.rb +30 -0
  36. data/lib/infinity_test/framework/phoenix.rb +72 -0
  37. data/lib/infinity_test/framework/python_package.rb +97 -0
  38. data/lib/infinity_test/framework/rails.rb +26 -0
  39. data/lib/infinity_test/framework/rocket.rb +70 -0
  40. data/lib/infinity_test/framework/rubygems.rb +29 -0
  41. data/lib/infinity_test/framework/rust_cargo.rb +69 -0
  42. data/lib/infinity_test/framework/shared_example.rb +47 -0
  43. data/lib/infinity_test/observer/base.rb +40 -0
  44. data/lib/infinity_test/observer/filewatcher.rb +72 -0
  45. data/lib/infinity_test/observer/listen.rb +74 -0
  46. data/lib/infinity_test/observer/shared_example.rb +35 -0
  47. data/lib/infinity_test/old_dsl/configuration.rb +26 -0
  48. data/lib/infinity_test/strategy/base.rb +50 -0
  49. data/lib/infinity_test/strategy/elixir_default.rb +20 -0
  50. data/lib/infinity_test/strategy/python_default.rb +22 -0
  51. data/lib/infinity_test/strategy/rbenv.rb +34 -0
  52. data/lib/infinity_test/strategy/ruby_default.rb +21 -0
  53. data/lib/infinity_test/strategy/rust_default.rb +21 -0
  54. data/lib/infinity_test/strategy/rvm.rb +52 -0
  55. data/lib/infinity_test/strategy/shared_example.rb +32 -0
  56. data/lib/infinity_test/test_framework/base.rb +64 -0
  57. data/lib/infinity_test/test_framework/cargo_test.rb +49 -0
  58. data/lib/infinity_test/test_framework/ex_unit.rb +53 -0
  59. data/lib/infinity_test/test_framework/pytest.rb +65 -0
  60. data/lib/infinity_test/test_framework/rspec.rb +48 -0
  61. data/lib/infinity_test/test_framework/shared_example.rb +56 -0
  62. data/lib/infinity_test/test_framework/test_unit.rb +57 -0
  63. data/lib/infinity_test.rb +66 -35
  64. data/spec/infinity_test/core/auto_discover_spec.rb +175 -0
  65. data/spec/infinity_test/core/base_spec.rb +240 -0
  66. data/spec/infinity_test/core/callback_spec.rb +89 -0
  67. data/spec/infinity_test/core/changed_file_spec.rb +26 -0
  68. data/spec/infinity_test/core/command_builder_spec.rb +38 -0
  69. data/spec/infinity_test/core/configuration_merge_spec.rb +124 -0
  70. data/spec/infinity_test/core/continuous_test_server_spec.rb +116 -0
  71. data/spec/infinity_test/core/load_configuration_spec.rb +43 -0
  72. data/spec/infinity_test/core/notifier_spec.rb +151 -0
  73. data/spec/infinity_test/core/options_spec.rb +168 -0
  74. data/spec/infinity_test/core/runner_spec.rb +17 -0
  75. data/spec/infinity_test/framework/base_spec.rb +55 -0
  76. data/spec/infinity_test/framework/django_spec.rb +95 -0
  77. data/spec/infinity_test/framework/elixir_mix_spec.rb +44 -0
  78. data/spec/infinity_test/framework/fast_api_spec.rb +96 -0
  79. data/spec/infinity_test/framework/padrino_spec.rb +58 -0
  80. data/spec/infinity_test/framework/phoenix_spec.rb +85 -0
  81. data/spec/infinity_test/framework/python_package_spec.rb +95 -0
  82. data/spec/infinity_test/framework/rails_spec.rb +58 -0
  83. data/spec/infinity_test/framework/rocket_spec.rb +69 -0
  84. data/spec/infinity_test/framework/rubygems_spec.rb +34 -0
  85. data/spec/infinity_test/framework/rust_cargo_spec.rb +94 -0
  86. data/spec/infinity_test/observer/base_spec.rb +78 -0
  87. data/spec/infinity_test/observer/filewatcher_spec.rb +51 -0
  88. data/spec/infinity_test/observer/listen_spec.rb +50 -0
  89. data/spec/infinity_test/{builder_spec.rb → strategy/base_spec.rb} +1 -2
  90. data/spec/infinity_test/strategy/elixir_default_spec.rb +46 -0
  91. data/spec/infinity_test/strategy/python_default_spec.rb +56 -0
  92. data/spec/infinity_test/strategy/rbenv_spec.rb +70 -0
  93. data/spec/infinity_test/strategy/ruby_default_spec.rb +49 -0
  94. data/spec/infinity_test/strategy/rust_default_spec.rb +56 -0
  95. data/spec/infinity_test/strategy/rvm_spec.rb +86 -0
  96. data/spec/infinity_test/test_framework/cargo_test_spec.rb +145 -0
  97. data/spec/infinity_test/test_framework/ex_unit_spec.rb +153 -0
  98. data/spec/infinity_test/test_framework/pytest_spec.rb +182 -0
  99. data/spec/infinity_test/test_framework/rspec_spec.rb +119 -0
  100. data/spec/infinity_test/test_framework/test_unit_spec.rb +193 -0
  101. data/spec/spec_helper.rb +34 -119
  102. metadata +315 -177
  103. data/.rvmrc +0 -1
  104. data/Gemfile.lock +0 -62
  105. data/Readme.markdown +0 -147
  106. data/Tasks +0 -4
  107. data/VERSION.yml +0 -5
  108. data/buzz_images/buzz_lightyear.jpg +0 -0
  109. data/buzz_images/buzz_lightyear_continencia.gif +0 -0
  110. data/buzz_images/to_infinity_and_beyond.png +0 -0
  111. data/features/heuristics.feature +0 -23
  112. data/features/support/env.rb +0 -2
  113. data/images/fuuu/sucess.png +0 -0
  114. data/lib/infinity_test/application.rb +0 -362
  115. data/lib/infinity_test/application_library/rails.rb +0 -94
  116. data/lib/infinity_test/application_library/rubygems.rb +0 -43
  117. data/lib/infinity_test/binary_path.rb +0 -43
  118. data/lib/infinity_test/builder.rb +0 -66
  119. data/lib/infinity_test/command.rb +0 -58
  120. data/lib/infinity_test/configuration.rb +0 -277
  121. data/lib/infinity_test/continuous_testing.rb +0 -40
  122. data/lib/infinity_test/dependencies.rb +0 -80
  123. data/lib/infinity_test/environment.rb +0 -15
  124. data/lib/infinity_test/heuristics.rb +0 -36
  125. data/lib/infinity_test/heuristics_helper.rb +0 -9
  126. data/lib/infinity_test/options.rb +0 -96
  127. data/lib/infinity_test/runner.rb +0 -38
  128. data/lib/infinity_test/test_framework.rb +0 -110
  129. data/lib/infinity_test/test_library/bacon.rb +0 -55
  130. data/lib/infinity_test/test_library/cucumber.rb +0 -22
  131. data/lib/infinity_test/test_library/rspec.rb +0 -60
  132. data/lib/infinity_test/test_library/test_unit.rb +0 -52
  133. data/lib/infinity_test/test_unit_loader.rb +0 -5
  134. data/spec/factories/buzz/lib/buzz.rb +0 -0
  135. data/spec/factories/buzz/spec/buzz_spec.rb +0 -0
  136. data/spec/factories/company/Gemfile +0 -0
  137. data/spec/factories/company/lib/company.rb +0 -0
  138. data/spec/factories/company/test/company_test.rb +0 -0
  139. data/spec/factories/images/failure.png +0 -0
  140. data/spec/factories/images/pending.png +0 -0
  141. data/spec/factories/images/sucess.png +0 -0
  142. data/spec/factories/infinity_test +0 -5
  143. data/spec/factories/infinity_test_example +0 -7
  144. data/spec/factories/slinky/spec/slinky/slinky_spec.rb +0 -0
  145. data/spec/factories/travel/lib/travel.rb +0 -0
  146. data/spec/factories/travel/test/partner_test.rb +0 -0
  147. data/spec/factories/travel/test/travel_test.rb +0 -0
  148. data/spec/factories/wood/lib/wood.rb +0 -0
  149. data/spec/factories/wood/spec/wood_spec.rb +0 -0
  150. data/spec/infinity_test/application_library/rails_spec.rb +0 -140
  151. data/spec/infinity_test/application_library/rubygems_spec.rb +0 -52
  152. data/spec/infinity_test/application_spec.rb +0 -434
  153. data/spec/infinity_test/binary_path_spec.rb +0 -72
  154. data/spec/infinity_test/command_spec.rb +0 -53
  155. data/spec/infinity_test/configuration_spec.rb +0 -382
  156. data/spec/infinity_test/continuous_testing_spec.rb +0 -25
  157. data/spec/infinity_test/environment_spec.rb +0 -23
  158. data/spec/infinity_test/heuristics_helper_spec.rb +0 -15
  159. data/spec/infinity_test/heuristics_spec.rb +0 -127
  160. data/spec/infinity_test/options_spec.rb +0 -111
  161. data/spec/infinity_test/runner_spec.rb +0 -42
  162. data/spec/infinity_test/test_framework_spec.rb +0 -127
  163. data/spec/infinity_test/test_library/bacon_spec.rb +0 -150
  164. data/spec/infinity_test/test_library/cucumber_spec.rb +0 -8
  165. data/spec/infinity_test/test_library/rspec_spec.rb +0 -189
  166. data/spec/infinity_test/test_library/test_unit_spec.rb +0 -184
  167. data/spec/infinity_test_spec.rb +0 -40
  168. /data/images/faces/{sucess.png → success.png} +0 -0
  169. /data/images/hands/{sucess.png → success.png} +0 -0
  170. /data/images/mario_bros/{sucess.jpg → success.jpg} +0 -0
  171. /data/images/rails/{sucess.png → success.png} +0 -0
  172. /data/images/rubies/{sucess.png → success.png} +0 -0
  173. /data/images/simpson/{sucess.jpg → success.jpg} +0 -0
  174. /data/images/street_fighter/{sucess.jpg → success.jpg} +0 -0
  175. /data/images/toy_story/{sucess.png → success.png} +0 -0
@@ -0,0 +1,50 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class Base
4
+ def initialize(continuous_test_server)
5
+ @continuous_test_server = continuous_test_server
6
+ end
7
+
8
+ # ==== Returns
9
+ # CommandBuilderClass: A class that builds that command using method_missing.
10
+ #
11
+ def command_builder
12
+ Core::CommandBuilder.new
13
+ end
14
+
15
+ # Run the strategy and parse the results storing in the strategy.
16
+ # Prints the command before executing if verbose mode is enabled.
17
+ #
18
+ def run
19
+ command = run!
20
+ puts "\n\e[96m[InfinityTest]\e[0m - Command: '\e[32m#{command}\e[0m'\n\n" if Core::Base.verbose?
21
+ Core::CommandRunner.new(command)
22
+ end
23
+
24
+ # Check if bundler should be used.
25
+ # Returns true if bundler is enabled and Gemfile exists.
26
+ #
27
+ def use_bundler?
28
+ Core::Base.using_bundler? && File.exist?('Gemfile')
29
+ end
30
+
31
+ # Wrap command with bundle exec if bundler should be used.
32
+ #
33
+ def with_bundler(command)
34
+ use_bundler? ? "bundle exec #{command}" : command
35
+ end
36
+
37
+ # Implement #run! method returning a string command to be run.
38
+ #
39
+ def run!
40
+ raise NotImplementedError, "not implemented in #{self}"
41
+ end
42
+
43
+ # Put all the requires to autodiscover use your strategy instead of others.
44
+ #
45
+ def self.run?
46
+ raise NotImplementedError, "not implemented in #{self}"
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,20 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class ElixirDefault < Base
4
+ attr_reader :continuous_test_server
5
+ delegate :binary, :test_files, to: :continuous_test_server
6
+
7
+ def run!
8
+ command = "#{binary} test #{test_files}"
9
+ command = "#{command} #{Core::Base.specific_options}" if Core::Base.specific_options.present?
10
+ command
11
+ end
12
+
13
+ # Run when the project has mix.exs (Elixir project)
14
+ #
15
+ def self.run?
16
+ File.exist?('mix.exs')
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class PythonDefault < Base
4
+ attr_reader :continuous_test_server
5
+ delegate :binary, :test_files, to: :continuous_test_server
6
+
7
+ def run!
8
+ command = "#{binary} #{test_files}"
9
+ command = "#{command} #{Core::Base.specific_options}" if Core::Base.specific_options.present?
10
+ command
11
+ end
12
+
13
+ # Run when the project has Python package files
14
+ #
15
+ def self.run?
16
+ File.exist?('pyproject.toml') ||
17
+ File.exist?('setup.py') ||
18
+ File.exist?('setup.cfg')
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class Rbenv < Base
4
+ attr_reader :continuous_test_server
5
+ delegate :binary, :test_files, to: :continuous_test_server
6
+
7
+ # Build and run commands for each ruby version specified.
8
+ # Uses rbenv's RBENV_VERSION environment variable to run tests in different Ruby environments.
9
+ #
10
+ # ==== Returns
11
+ # String: The command string for all ruby versions joined with &&
12
+ #
13
+ def run!
14
+ rubies = Core::Base.rubies
15
+
16
+ commands = rubies.map do |ruby_version|
17
+ test_command = "#{binary} #{test_files}"
18
+ test_command = with_bundler(test_command)
19
+ "RBENV_VERSION=#{ruby_version} #{test_command}"
20
+ end
21
+
22
+ commands.join(' && ')
23
+ end
24
+
25
+ # ==== Returns
26
+ # TrueClass: If the user has rbenv installed AND has specified rubies to test against.
27
+ # FalseClass: If rbenv is not installed OR no rubies are specified.
28
+ #
29
+ def self.run?
30
+ Core::Base.rubies.present? && File.exist?(File.expand_path('~/.rbenv'))
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,21 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class RubyDefault < Base
4
+ attr_reader :continuous_test_server
5
+ delegate :binary, :test_files, to: :continuous_test_server
6
+
7
+ def run!
8
+ command = "#{binary} #{test_files}"
9
+ with_bundler(command)
10
+ end
11
+
12
+ # ==== Returns
13
+ # TrueClass: If the user don't pass the ruby versions to run tests.
14
+ # FalseClass: If the user pass some ruby version to run tests.
15
+ #
16
+ def self.run?
17
+ Core::Base.rubies.blank?
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class RustDefault < Base
4
+ attr_reader :continuous_test_server
5
+ delegate :binary, :test_files, to: :continuous_test_server
6
+
7
+ def run!
8
+ command = "#{binary} test"
9
+ command = "#{command} #{test_files}" if test_files.present?
10
+ command = "#{command} #{Core::Base.specific_options}" if Core::Base.specific_options.present?
11
+ command
12
+ end
13
+
14
+ # Run when the project has Cargo.toml (Rust project)
15
+ #
16
+ def self.run?
17
+ File.exist?('Cargo.toml')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,52 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ class Rvm < Base
4
+ attr_reader :continuous_test_server
5
+ delegate :binary, :test_files, to: :continuous_test_server
6
+
7
+ # Build and run commands for each ruby version specified.
8
+ # Uses RVM's `rvm <version> do` syntax to run tests in different Ruby environments.
9
+ #
10
+ # ==== Returns
11
+ # String: The command string for the first ruby version (others run sequentially)
12
+ #
13
+ def run!
14
+ rubies = Core::Base.rubies
15
+ gemset = Core::Base.gemset
16
+
17
+ commands = rubies.map do |ruby_version|
18
+ ruby_with_gemset = gemset.present? ? "#{ruby_version}@#{gemset}" : ruby_version
19
+ test_command = "#{binary} #{test_files}"
20
+ test_command = with_bundler(test_command)
21
+ "rvm #{ruby_with_gemset} do #{test_command}"
22
+ end
23
+
24
+ commands.join(' && ')
25
+ end
26
+
27
+ # ==== Returns
28
+ # TrueClass: If the user has RVM installed AND has specified rubies to test against.
29
+ # FalseClass: If RVM is not installed OR no rubies are specified.
30
+ #
31
+ def self.run?
32
+ Core::Base.rubies.present? && (installed_users_home? || installed_system_wide?)
33
+ end
34
+
35
+ # ==== Returns
36
+ # TrueClass: Find rvm installed in ~/.rvm.
37
+ # FalseClass: Don't Find rvm installed in ~/.rvm.
38
+ #
39
+ def self.installed_users_home?
40
+ File.exist?(File.expand_path('~/.rvm'))
41
+ end
42
+
43
+ # ==== Returns
44
+ # TrueClass: Find rvm installed in /usr/local/rvm.
45
+ # FalseClass: Don't Find rvm installed in /usr/local/rvm.
46
+ #
47
+ def self.installed_system_wide?
48
+ File.exist?(File.expand_path("/usr/local/rvm"))
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,32 @@
1
+ module InfinityTest
2
+ module Strategy
3
+ module SharedExample
4
+ # Shared Examples to use in the RSpec specs when you want create your own strategy
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # RSpec.configure do |config|
9
+ # config.include InfinityTest::Strategy::SharedExample
10
+ # end
11
+ #
12
+ # describe FooStrategy do
13
+ # subject { FooStrategy.new(InfinityTest::Core::Base) }
14
+ # it_should_behave_like 'a infinity test strategy'
15
+ # end
16
+ #
17
+ shared_examples_for 'a infinity test strategy' do
18
+ it 'responds to #run!' do
19
+ expect(subject).to respond_to(:run)
20
+ end
21
+
22
+ it 'responds to .run?' do
23
+ expect(subject.class).to respond_to(:run?)
24
+ end
25
+
26
+ it 'has Strategy::Base as superclass' do
27
+ expect(subject.class.superclass).to be InfinityTest::Strategy::Base
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,64 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ class Base
4
+ attr_writer :test_files
5
+ attr_reader :test_message
6
+
7
+ def test_helper_file
8
+ raise NotImplementedError, "not implemented in #{self}"
9
+ end
10
+
11
+ def test_dir
12
+ raise NotImplementedError, "not implemented in #{self}"
13
+ end
14
+
15
+ def test_dir=(dir)
16
+ raise NotImplementedError, "not implemented in #{self}"
17
+ end
18
+
19
+ def binary
20
+ raise NotImplementedError, "not implemented in #{self}"
21
+ end
22
+
23
+ # Parse the test results based by the framework patterns.
24
+ # <b>The subclass must implement the #patterns method.</b>
25
+ #
26
+ def test_message=(message)
27
+ @test_message = final_results(message).join.gsub(/\e\[\d+?m/, '') # Clean ANSIColor strings
28
+
29
+ patterns.each do |key, pattern|
30
+ spec_number = test_message[pattern, 1].to_i
31
+ instance_variable_set("@#{key}", spec_number)
32
+ end
33
+
34
+ @test_message
35
+ end
36
+
37
+ def patterns
38
+ raise NotImplementedError, "not implemented in #{self}"
39
+ end
40
+
41
+ def success?
42
+ raise NotImplementedError, "not implemented in #{self}"
43
+ end
44
+
45
+ def failure?
46
+ raise NotImplementedError, "not implemented in #{self}"
47
+ end
48
+
49
+ def pending?
50
+ raise NotImplementedError, "not implemented in #{self}"
51
+ end
52
+
53
+ private
54
+
55
+ def final_results(message)
56
+ lines = message.split("\n")
57
+
58
+ patterns.map do |pattern_name, pattern|
59
+ lines.find { |line| line =~ pattern }
60
+ end.flatten.uniq
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,49 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ class CargoTest < Base
4
+ def binary
5
+ 'cargo'
6
+ end
7
+
8
+ def test_helper_file
9
+ 'Cargo.toml'
10
+ end
11
+
12
+ def test_dir
13
+ @test_dir ||= 'tests'
14
+ end
15
+
16
+ def test_dir=(dir)
17
+ @test_dir = dir
18
+ end
19
+
20
+ def test_files
21
+ @test_files || ''
22
+ end
23
+
24
+ # Cargo test output patterns:
25
+ # "test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out"
26
+ # "test result: FAILED. 3 passed; 2 failed; 1 ignored; 0 measured; 0 filtered out"
27
+ #
28
+ def patterns
29
+ { passed: /(\d+) passed/, failed: /(\d+) failed/, ignored: /(\d+) ignored/ }
30
+ end
31
+
32
+ def success?
33
+ @failed.zero? && @ignored.zero?
34
+ end
35
+
36
+ def failure?
37
+ @failed > 0
38
+ end
39
+
40
+ def pending?
41
+ @ignored > 0
42
+ end
43
+
44
+ def self.run?
45
+ File.exist?('Cargo.toml')
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,53 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ class ExUnit < Base
4
+ def binary
5
+ 'mix'
6
+ end
7
+
8
+ def test_helper_file
9
+ File.join(test_dir, 'test_helper.exs')
10
+ end
11
+
12
+ def test_dir
13
+ @test_dir ||= 'test'
14
+ end
15
+
16
+ def test_dir=(dir)
17
+ @test_dir = dir
18
+ end
19
+
20
+ def test_files
21
+ @test_files || test_dir
22
+ end
23
+
24
+ # ExUnit output patterns:
25
+ # "3 tests, 0 failures"
26
+ # "3 tests, 1 failure"
27
+ # "3 tests, 0 failures, 1 skipped"
28
+ #
29
+ def patterns
30
+ { tests: /(\d+) tests?/, failures: /(\d+) failures?/, skipped: /(\d+) skipped/ }
31
+ end
32
+
33
+ def success?
34
+ @failures.zero? && @skipped.zero?
35
+ end
36
+
37
+ def failure?
38
+ @failures > 0
39
+ end
40
+
41
+ def pending?
42
+ @skipped > 0
43
+ end
44
+
45
+ def self.run?
46
+ File.exist?('test') && (
47
+ File.exist?('test/test_helper.exs') ||
48
+ Dir['test/**/*_test.exs'].any?
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,65 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ class Pytest < Base
4
+ def binary
5
+ 'pytest'
6
+ end
7
+
8
+ def test_helper_file
9
+ File.join(test_dir, 'conftest.py')
10
+ end
11
+
12
+ def test_dir
13
+ @test_dir ||= detect_test_dir
14
+ end
15
+
16
+ def test_dir=(dir)
17
+ @test_dir = dir
18
+ end
19
+
20
+ def test_files
21
+ @test_files || test_dir
22
+ end
23
+
24
+ # Pytest output patterns:
25
+ # "5 passed in 0.12s"
26
+ # "1 failed, 4 passed in 0.15s"
27
+ # "1 failed, 2 passed, 1 skipped in 0.20s"
28
+ #
29
+ def patterns
30
+ { passed: /(\d+) passed/, failed: /(\d+) failed/, skipped: /(\d+) skipped/ }
31
+ end
32
+
33
+ def success?
34
+ @failed.zero? && @skipped.zero?
35
+ end
36
+
37
+ def failure?
38
+ @failed > 0
39
+ end
40
+
41
+ def pending?
42
+ @skipped > 0
43
+ end
44
+
45
+ def self.run?
46
+ (File.exist?('tests') || File.exist?('test')) && (
47
+ File.exist?('tests/conftest.py') ||
48
+ File.exist?('test/conftest.py') ||
49
+ Dir['tests/**/test_*.py'].any? ||
50
+ Dir['test/**/test_*.py'].any? ||
51
+ Dir['tests/**/*_test.py'].any? ||
52
+ Dir['test/**/*_test.py'].any?
53
+ )
54
+ end
55
+
56
+ private
57
+
58
+ def detect_test_dir
59
+ return 'tests' if File.exist?('tests')
60
+ return 'test' if File.exist?('test')
61
+ 'tests'
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,48 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ class Rspec < Base
4
+ def binary
5
+ 'rspec'
6
+ end
7
+
8
+ def test_helper_file
9
+ File.join(test_dir, 'spec_helper.rb')
10
+ end
11
+
12
+ def test_dir
13
+ @test_dir ||= 'spec'
14
+ end
15
+
16
+ def test_dir=(dir)
17
+ @test_dir = dir
18
+ end
19
+
20
+ def test_files
21
+ @test_files || test_dir
22
+ end
23
+
24
+ def patterns
25
+ { :examples => /(\d+) example/, :failures => /(\d+) failure/, :pending => /(\d+) pending/ }
26
+ end
27
+
28
+ def success?
29
+ @failures.zero? and @pending.zero?
30
+ end
31
+
32
+ def failure?
33
+ @failures > 0
34
+ end
35
+
36
+ def pending?
37
+ @pending > 0
38
+ end
39
+
40
+ def self.run?
41
+ File.exist?('spec') && (
42
+ File.exist?('spec/spec_helper.rb') ||
43
+ Dir['spec/**/*_spec.rb'].any?
44
+ )
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,56 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ module SharedExample
4
+ # Shared Examples to use in the RSpec specs when you want create your own infinity test wrapper test framework
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # RSpec.configure do |config|
9
+ # config.include InfinityTest::TestFramework::SharedExample
10
+ # end
11
+ #
12
+ # describe FooTestFramework do
13
+ # subject { FooStrategy.new(InfinityTest::Core::Base) }
14
+ # it_should_behave_like 'a infinity test test framework'
15
+ # end
16
+ #
17
+ shared_examples_for 'a infinity test test framework' do
18
+ it 'responds to #test_message=' do
19
+ expect(subject).to respond_to(:test_message=)
20
+ end
21
+
22
+ it 'responds to #test_message' do
23
+ expect(subject).to respond_to(:test_message)
24
+ end
25
+
26
+ it 'responds to #succeed?' do
27
+ expect(subject).to respond_to(:success?)
28
+ end
29
+
30
+ it 'responds to #failure?' do
31
+ expect(subject).to respond_to(:failure?)
32
+ end
33
+
34
+ it 'responds to #pending?' do
35
+ expect(subject).to respond_to(:pending?)
36
+ end
37
+
38
+ it 'responds to #test_helper_file' do
39
+ expect(subject).to respond_to(:test_helper_file)
40
+ end
41
+
42
+ it 'responds to #test_dir' do
43
+ expect(subject).to respond_to(:test_dir)
44
+ end
45
+
46
+ it 'responds to #test_dir=' do
47
+ expect(subject).to respond_to(:test_dir=)
48
+ end
49
+
50
+ it 'responds to #binary' do
51
+ expect(subject).to respond_to(:binary)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,57 @@
1
+ module InfinityTest
2
+ module TestFramework
3
+ class TestUnit < Base
4
+ def test_dir
5
+ @test_dir ||= 'test'
6
+ end
7
+
8
+ def test_dir=(dir)
9
+ @test_dir = dir
10
+ end
11
+
12
+ def test_helper_file
13
+ File.join(test_dir, 'test_helper.rb')
14
+ end
15
+
16
+ def test_files
17
+ @test_files || test_dir
18
+ end
19
+
20
+ def binary
21
+ 'ruby'
22
+ end
23
+
24
+ # Patterns for parsing minitest/test-unit output
25
+ # Example: "10 runs, 15 assertions, 0 failures, 0 errors, 0 skips"
26
+ def patterns
27
+ {
28
+ :runs => /(\d+) runs,/,
29
+ :assertions => /(\d+) assertions,/,
30
+ :failures => /(\d+) failures,/,
31
+ :errors => /(\d+) errors,/,
32
+ :skips => /(\d+) skips/
33
+ }
34
+ end
35
+
36
+ def success?
37
+ @failures.zero? && @errors.zero? && @skips.zero?
38
+ end
39
+
40
+ def failure?
41
+ @failures > 0 || @errors > 0
42
+ end
43
+
44
+ def pending?
45
+ @skips > 0
46
+ end
47
+
48
+ def self.run?
49
+ File.exist?('test') && (
50
+ File.exist?('test/test_helper.rb') ||
51
+ Dir['test/**/*_test.rb'].any? ||
52
+ Dir['test/**/test_*.rb'].any?
53
+ )
54
+ end
55
+ end
56
+ end
57
+ end