eac_redmine_base0 0.3.4 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95d72359e3318bc85e2c3f2efd13b782ecdfd27f5e144c6cc5cbd2b27c4659a0
4
- data.tar.gz: c1cec1f021f6bcdca5f8afcf899ff0d14daec2169bf6bee80524b9af9f0eed2d
3
+ metadata.gz: 2b1d04912b952e1e0f675a69e83c4f451f4a85d0d7d22d4b70e8608c390668be
4
+ data.tar.gz: 34bc31720ee8369d20cd473ba708df6e90033fcab02bd9c310036a6b3ad9df6e
5
5
  SHA512:
6
- metadata.gz: 9bf70fbb6c3410e1d365133bb91601f9eb84cc3a237a4ec81bff80a379d518e422fe3bef831489dea56336f8f779325d683ddf846cc0061526deee65500c4f39
7
- data.tar.gz: 75728edd2a79097cdc70ec7cf8d7053cbed99040e23b3e74454aafed0d1aae92bfe2a0367ec38a9fdf4df4b46f60c2b30c82121d340a4631bf4024bc50fdd159
6
+ metadata.gz: 7500c4beeb108d6d2d06e2c818dc5991663e6706517ed3031c19d3048209060edbc6c2309ff951bf872ffdab632137d919510b68c1d17cc9bfabfaa60ce69689
7
+ data.tar.gz: 7326614d2822ffcb1b148f89e5ccf5fe05a6e56be84444eebc2c9427e32e7abedbe59f8eb41cbdd71ef973ca8d9737298c39010cdef8f1269d3fe8a9a3a4b6c0
@@ -1,17 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/result'
4
- require 'eac_ruby_gems_utils/gem'
5
3
  require 'eac_ruby_utils/console/speaker'
6
4
  require 'eac_ruby_utils/envs'
7
- require 'eac_ruby_utils/simple_cache'
8
5
 
9
6
  module EacRedmineBase0
10
7
  class PluginsTest
11
8
  include ::EacRubyUtils::Console::Speaker
12
9
 
13
10
  def run
14
- @plugins = []
11
+ @tests = []
15
12
  ::Redmine::Plugin.registered_plugins.each_value do |plugin|
16
13
  check_plugin(plugin)
17
14
  end
@@ -19,92 +16,35 @@ module EacRedmineBase0
19
16
  end
20
17
 
21
18
  def check_plugin(plugin)
22
- infom "Checking plugin \"#{plugin.id}\"..."
23
- test_plugin = PluginTest.new(plugin)
24
- test_plugin.test_result
25
- infom "Plugin \"#{plugin.id}\" checked"
26
- @plugins << test_plugin
19
+ ::EacRedmineBase0::PluginsTest::Plugin.new(plugin).tests.each { |test| check_test(test) }
20
+ end
21
+
22
+ def check_test(test)
23
+ infom "Checking test \"#{test}\"..."
24
+ test.test_result
25
+ infom "Test \"#{test}\" checked"
26
+ @tests << test
27
27
  results_banner
28
28
  end
29
29
 
30
30
  def results_banner
31
- infom 'Plugins\' test results:'
32
- @plugins.each do |plugin|
33
- infov " * #{plugin.id}", plugin.test_result.label
31
+ infom 'Tests\' results:'
32
+ @tests.each do |test|
33
+ infov " * #{test}", test.test_result.label
34
34
  end
35
35
  end
36
36
 
37
- def plugins_failed
38
- @plugins.select { |plugin| plugin.test_result.error? }
37
+ def tests_failed
38
+ @tests.select { |test| test.test_result.error? }
39
39
  end
40
40
 
41
41
  def check_results
42
- if plugins_failed.any?
42
+ if tests_failed.any?
43
43
  fatal_error "Some test did not pass:\n" +
44
- plugins_failed.map { |p| " * #{p.id} (Log: #{p.stdout_log})" }.join("\n")
44
+ tests_failed.map { |test| " * #{test} (Log: #{test.stdout_log})" }.join("\n")
45
45
  else
46
46
  success 'All tests passed'
47
47
  end
48
48
  end
49
-
50
- class PluginTest < ::SimpleDelegator
51
- include ::EacRubyUtils::SimpleCache
52
-
53
- def initialize(plugin)
54
- super(plugin)
55
- end
56
-
57
- def test_task_name
58
- "#{id}:test"
59
- end
60
-
61
- def test_task?
62
- ::Rake::Task.task_defined?(test_task_name)
63
- end
64
-
65
- def stderr_log
66
- log_path('stderr')
67
- end
68
-
69
- def stdout_log
70
- log_path('stdout')
71
- end
72
-
73
- def maintained?
74
- ::EacRedmineBase0.maintained_plugins.any? { |plugin| plugin.id == id }
75
- end
76
-
77
- private
78
-
79
- def log_path(suffix)
80
- r = ::Rails.root.join('log', 'eac_redmine_base0', "#{id}_test_#{suffix}.log")
81
- ::FileUtils.mkdir_p(::File.dirname(r))
82
- r
83
- end
84
-
85
- def test_result_uncached
86
- return ::Avm::Result.neutral('not maintained by E.A.C.') unless maintained?
87
- return ::Avm::Result.neutral("task \"#{test_task_name}\" not found") unless test_task?
88
-
89
- ::Avm::Result.success_or_error(
90
- run_test, 'success', "failed (Log: #{stdout_log})"
91
- )
92
- end
93
-
94
- def rails_gem_uncached
95
- ::EacRubyGemsUtils::Gem.new(::Rails.root)
96
- end
97
-
98
- def run_test_uncached
99
- r = run_test_command.execute
100
- ::File.write(stderr_log, r.fetch(:stderr))
101
- ::File.write(stdout_log, r.fetch(:stdout))
102
- r.fetch(:exit_code).zero?
103
- end
104
-
105
- def run_test_command
106
- rails_gem.bundle('exec', 'rake', test_task_name).envvar('RAILS_ENV', 'test')
107
- end
108
- end
109
49
  end
110
50
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRedmineBase0
6
+ class PluginsTest
7
+ class BaseTest
8
+ enable_simple_cache
9
+ common_constructor :plugin
10
+
11
+ def stderr_log
12
+ log_path('stderr')
13
+ end
14
+
15
+ def stdout_log
16
+ log_path('stdout')
17
+ end
18
+
19
+ def test_name
20
+ self.class.name.demodulize.gsub(/Test\z/, '').underscore
21
+ end
22
+
23
+ def to_s
24
+ "#{plugin.id}/#{test_name}"
25
+ end
26
+
27
+ private
28
+
29
+ def log_path(suffix)
30
+ r = ::Rails.root.join('log', 'eac_redmine_base0',
31
+ "#{plugin.id}_#{self.class.name.demodulize.underscore}_#{suffix}.log")
32
+ ::FileUtils.mkdir_p(::File.dirname(r))
33
+ r
34
+ end
35
+
36
+ def run_test_uncached
37
+ r = run_test_command.execute
38
+ ::File.write(stderr_log, r.fetch(:stderr))
39
+ ::File.write(stdout_log, r.fetch(:stdout))
40
+ r.fetch(:exit_code).zero?
41
+ end
42
+
43
+ def test_result_uncached
44
+ ::Avm::Result.success_or_error(
45
+ run_test, 'success', "failed (Log: #{stdout_log})"
46
+ )
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/configuration' # TO-DO: remove when fixed in gem "avm-tools"
4
+ require 'avm/patches/eac_ruby_gems_utils/gem'
5
+ require 'avm/result'
6
+ require 'eac_ruby_utils/simple_cache'
7
+
8
+ module EacRedmineBase0
9
+ class PluginsTest
10
+ class Plugin < ::SimpleDelegator
11
+ include ::EacRubyUtils::SimpleCache
12
+
13
+ def initialize(plugin)
14
+ super(plugin)
15
+ end
16
+
17
+ def maintained?
18
+ ::EacRedmineBase0.maintained_plugins.any? { |plugin| plugin.id == id }
19
+ end
20
+
21
+ def tests
22
+ return [test_by_type(:unmaintened_stub)] unless maintained?
23
+
24
+ [test_by_type(:rake_task), test_by_type(:rubocop)]
25
+ end
26
+
27
+ private
28
+
29
+ def test_by_type(type)
30
+ ::EacRedmineBase0::PluginsTest.const_get(type.to_s.camelize + 'Test').new(self)
31
+ end
32
+
33
+ def plugin_gem_uncached
34
+ ::EacRubyGemsUtils::Gem.new(directory)
35
+ end
36
+
37
+ def rails_gem_uncached
38
+ ::EacRubyGemsUtils::Gem.new(::Rails.root)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRedmineBase0
6
+ class PluginsTest
7
+ class RakeTaskTest < ::EacRedmineBase0::PluginsTest::BaseTest
8
+ def test_task?
9
+ ::Rake::Task.task_defined?(test_task_name)
10
+ end
11
+
12
+ def test_task_name
13
+ "#{plugin.id}:test"
14
+ end
15
+
16
+ private
17
+
18
+ def run_test_command
19
+ plugin.rails_gem.bundle('exec', 'rake', test_task_name).envvar('RAILS_ENV', 'test')
20
+ end
21
+
22
+ def test_result_uncached
23
+ return ::Avm::Result.neutral("task \"#{test_task_name}\" not found") unless test_task?
24
+
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRedmineBase0
6
+ class PluginsTest
7
+ class RubocopTest < ::EacRedmineBase0::PluginsTest::BaseTest
8
+ EXEC_NAME = GEM_NAME = 'rubocop'
9
+
10
+ def rubocop?
11
+ return false unless plugin.plugin_gem.gemfile_path.exist?
12
+
13
+ bundle_install_command.execute!
14
+ plugin.plugin_gem.gemfile_lock_gem_version(GEM_NAME).present?
15
+ end
16
+
17
+ private
18
+
19
+ def bundle_install_command
20
+ plugin.plugin_gem.bundle.chdir_root
21
+ end
22
+
23
+ def run_test_command
24
+ plugin.plugin_gem.bundle('exec', EXEC_NAME, '--ignore-parent-exclusion')
25
+ .envvar('RAILS_ENV', 'test')
26
+ .chdir_root
27
+ end
28
+
29
+ def test_result_uncached
30
+ return ::Avm::Result.neutral("gem \"#{GEM_NAME}\"not found") unless rubocop?
31
+
32
+ super
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRedmineBase0
6
+ class PluginsTest
7
+ class UnmaintenedStubTest < ::EacRedmineBase0::PluginsTest::BaseTest
8
+ private
9
+
10
+ def test_result_uncached
11
+ ::Avm::Result.neutral('not maintained by E.A.C.')
12
+ end
13
+ end
14
+ end
15
+ end
@@ -4,5 +4,5 @@ module EacRedmineBase0
4
4
  AUTHOR = 'Eduardo Henrique Bogoni'
5
5
  HOMEPAGE = 'https://github.com/esquilo-azul/eac_redmine_base0'
6
6
  SUMMARY = 'E.A.C. base for Redmine.'
7
- VERSION = '0.3.4'
7
+ VERSION = '0.4.0'
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_redmine_base0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
- - 0.3.4
7
+ - 0.4.0
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-01 00:00:00.000000000 Z
11
+ date: 2020-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm-tools
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.58'
19
+ version: '0.62'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.62.4
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '0.58'
29
+ version: '0.62'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.62.4
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: eac_ruby_gems_utils
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -68,6 +74,11 @@ files:
68
74
  - lib/eac_redmine_base0.rb
69
75
  - lib/eac_redmine_base0/maintained_plugins.rb
70
76
  - lib/eac_redmine_base0/plugins_test.rb
77
+ - lib/eac_redmine_base0/plugins_test/base_test.rb
78
+ - lib/eac_redmine_base0/plugins_test/plugin.rb
79
+ - lib/eac_redmine_base0/plugins_test/rake_task_test.rb
80
+ - lib/eac_redmine_base0/plugins_test/rubocop_test.rb
81
+ - lib/eac_redmine_base0/plugins_test/unmaintened_stub_test.rb
71
82
  - lib/eac_redmine_base0/version.rb
72
83
  - lib/tasks/eac_redmine_base0.rake
73
84
  homepage: https://github.com/esquilo-azul/eac_redmine_base0