avm 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/registry/base.rb +1 -1
- data/lib/avm/source_stereotypes/base.rb +16 -2
- data/lib/avm/source_stereotypes/tester.rb +52 -0
- data/lib/avm/sources/base/configuration.rb +37 -0
- data/lib/avm/sources/base.rb +5 -8
- data/lib/avm/sources/tests/builder.rb +83 -0
- data/lib/avm/sources/tests/performer.rb +35 -0
- data/lib/avm/sources/tests/result.rb +15 -0
- data/lib/avm/sources/tests/single.rb +56 -0
- data/lib/avm/sources/tests.rb +11 -0
- data/lib/avm/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d91283f650ac7149bffe3855f56221278b7b0f9f746f21664dfae12bd1c12676
|
4
|
+
data.tar.gz: edbdead4c7ea2190f3e3fa4f28f02d778c48e6e42356f79b1b489692c8cae03e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d6dabb1ba231db6ee5d6acab7f1a3ff2a1dcf0d0682628e640d3937b8340d596cda65d0bb2da782bcc2c722608d57f25565e6157a529bf5a213525e8ed571c5
|
7
|
+
data.tar.gz: 16c6d0697d89b1e6b08eab24ceafd842827d57a30106de1235e375c3d204408162da4d8b27c4feec3b16b4839e304720f2907f473cca7a9c5128463512092ab8
|
data/lib/avm/registry/base.rb
CHANGED
@@ -12,7 +12,7 @@ module Avm
|
|
12
12
|
def detect(*registered_initialize_args)
|
13
13
|
detect_optional(*registered_initialize_args) ||
|
14
14
|
raise("No registered module valid for #{registered_initialize_args}" \
|
15
|
-
" (Module suffix: #{module_suffix})")
|
15
|
+
" (Module suffix: #{module_suffix}, Available: #{registered_modules.join(', ')})")
|
16
16
|
end
|
17
17
|
|
18
18
|
def detect_optional(*registered_initialize_args)
|
@@ -1,21 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/source_stereotypes/tester'
|
3
4
|
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/envs'
|
4
6
|
|
5
7
|
module Avm
|
6
8
|
module SourceStereotypes
|
7
9
|
class Base
|
8
|
-
enable_abstract_methods
|
9
|
-
abstract_methods :valid?
|
10
10
|
common_constructor :source
|
11
11
|
|
12
12
|
def name
|
13
13
|
self.class.name
|
14
14
|
end
|
15
15
|
|
16
|
+
# @return [Avm::SourceStereotypes::Tester]
|
17
|
+
def tester
|
18
|
+
tester_class.new(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Class<Avm::SourceStereotypes::Tester>
|
22
|
+
def tester_class
|
23
|
+
Avm::SourceStereotypes::Tester
|
24
|
+
end
|
25
|
+
|
16
26
|
def to_s
|
17
27
|
name
|
18
28
|
end
|
29
|
+
|
30
|
+
def valid?
|
31
|
+
true
|
32
|
+
end
|
19
33
|
end
|
20
34
|
end
|
21
35
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module SourceStereotypes
|
7
|
+
class Tester
|
8
|
+
TEST_COMMAND_CONFIGURATION_KEY = :test_command
|
9
|
+
|
10
|
+
enable_simple_cache
|
11
|
+
common_constructor :source_stereotype
|
12
|
+
delegate :source, to: :source_stereotype
|
13
|
+
|
14
|
+
# @return [EacRubyUtils::Envs::Command, nil]
|
15
|
+
def test_command
|
16
|
+
source.read_configuration_as_shell_words(TEST_COMMAND_CONFIGURATION_KEY)
|
17
|
+
.if_present do |args|
|
18
|
+
::EacRubyUtils::Envs.local.command(args).chdir(source.path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def logs_uncached
|
25
|
+
::EacRubyUtils::Fs::Logs.new.add(:stdout).add(:stderr)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Avm::Sources::Tests::Result]
|
29
|
+
def result_uncached
|
30
|
+
return ::Avm::Sources::Tests::Result::NONEXISTENT if test_command.blank?
|
31
|
+
|
32
|
+
if execute_command_and_log(test_command)
|
33
|
+
::Avm::Sources::Tests::Result::SUCESSFUL
|
34
|
+
else
|
35
|
+
::Avm::Sources::Tests::Result::FAILED
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def run_test_command
|
40
|
+
execute_command_and_log(test_command)
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [true, false]
|
44
|
+
def execute_command_and_log(command)
|
45
|
+
r = command.execute
|
46
|
+
logs[:stdout].write(r[:stdout])
|
47
|
+
logs[:stderr].write(r[:stderr])
|
48
|
+
r[:exit_code].zero?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
5
|
+
require 'shellwords'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Sources
|
9
|
+
class Base
|
10
|
+
module Configuration
|
11
|
+
# @return [Array<String>, nil]
|
12
|
+
def read_configuration_as_shell_words(key)
|
13
|
+
configuration[key].if_present do |v|
|
14
|
+
v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v.to_s)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @return [Hash]
|
21
|
+
def configuration_uncached
|
22
|
+
::Avm::Sources::Configuration::FILENAMES.each do |filename|
|
23
|
+
file_path = path.join(filename)
|
24
|
+
return ::EacRubyUtils::Yaml.load_file(file_path).with_indifferent_access if
|
25
|
+
file_path.exist?
|
26
|
+
end
|
27
|
+
{}
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Avm::Sources::Configuration]
|
31
|
+
def old_configuration_uncached
|
32
|
+
::Avm::Sources::Configuration.find_in_path(path)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/avm/sources/base.rb
CHANGED
@@ -7,17 +7,19 @@ require 'eac_ruby_utils/core_ext'
|
|
7
7
|
module Avm
|
8
8
|
module Sources
|
9
9
|
class Base
|
10
|
-
require_sub __FILE__
|
10
|
+
require_sub __FILE__, include_modules: true
|
11
|
+
compare_by :path
|
11
12
|
enable_simple_cache
|
12
13
|
enable_listable
|
13
14
|
lists.add_symbol :option, :parent
|
14
15
|
common_constructor :path, :options, default: [{}] do
|
15
|
-
self.path = path.to_pathname
|
16
|
+
self.path = path.to_pathname.expand_path
|
16
17
|
self.options = self.class.lists.option.hash_keys_validate!(options)
|
17
18
|
end
|
18
19
|
|
19
|
-
delegate :locale, to: :
|
20
|
+
delegate :locale, to: :old_configuration
|
20
21
|
delegate :to_s, to: :path
|
22
|
+
delegate :tester, to: :stereotype
|
21
23
|
|
22
24
|
# @return [Avm::Sources::Base]
|
23
25
|
def parent
|
@@ -43,11 +45,6 @@ module Avm
|
|
43
45
|
|
44
46
|
private
|
45
47
|
|
46
|
-
# @return [Avm::Sources::Configuration]
|
47
|
-
def configuration_uncached
|
48
|
-
::Avm::Sources::Configuration.find_in_path(path) || ::Avm::Sources::Configuration.new
|
49
|
-
end
|
50
|
-
|
51
48
|
# @return [EacGit::Local]
|
52
49
|
def git_repo_uncached
|
53
50
|
::EacGit::Local.new(path)
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/sources/tests/performer'
|
4
|
+
require 'avm/sources/tests/single'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Sources
|
9
|
+
module Tests
|
10
|
+
class Builder
|
11
|
+
require_sub __FILE__
|
12
|
+
enable_immutable
|
13
|
+
|
14
|
+
immutable_accessor :include_main, :include_subs, type: :boolean
|
15
|
+
immutable_accessor :include_id, type: :array
|
16
|
+
common_constructor :main_source
|
17
|
+
|
18
|
+
def immutable_constructor_args
|
19
|
+
[main_source]
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Avm::Sources::Tests::Performer]
|
23
|
+
def performer
|
24
|
+
::Avm::Sources::Tests::Performer.new(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def selected_units
|
28
|
+
(select_units_from_subs + select_units_from_main + select_units_from_ids).sort.uniq
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @return [Array<Avm::Sources::Tests::Single>]
|
34
|
+
def available_units
|
35
|
+
@available_units ||= ([main_source] + main_source.subs)
|
36
|
+
.map { |a_source| create_unit(a_source) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def available_units_from_main
|
40
|
+
create_units([main_source])
|
41
|
+
end
|
42
|
+
|
43
|
+
def available_units_from_subs
|
44
|
+
create_units(main_source.subs)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Avm::Sources::Tests::Single]
|
48
|
+
def create_unit(source)
|
49
|
+
::Avm::Sources::Tests::Single.new(self, source)
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Array<Avm::Sources::Tests::Single>]
|
53
|
+
def create_units(sources)
|
54
|
+
sources.map { |a_source| create_unit(a_source) }
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [Avm::Sources::Tests::Single]
|
58
|
+
def create_unit_by_id(source_id)
|
59
|
+
r = available_units.find { |unit| unit.id == source_id }
|
60
|
+
return r if r
|
61
|
+
|
62
|
+
raise ::ArgumentError, "Source not found with ID=#{source_id}" \
|
63
|
+
"(Available: #{available_units.map(&:id).join(', ')})"
|
64
|
+
end
|
65
|
+
|
66
|
+
# @return [Array<Avm::Sources::Tests::Single>]
|
67
|
+
def select_units_from_ids
|
68
|
+
include_ids.map { |source_id| create_unit_by_id(source_id) }
|
69
|
+
end
|
70
|
+
|
71
|
+
# @return [Array<Avm::Sources::Tests::Single>]
|
72
|
+
def select_units_from_main
|
73
|
+
include_main? ? available_units_from_main : []
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [Array<Avm::Sources::Tests::Single>]
|
77
|
+
def select_units_from_subs
|
78
|
+
include_subs? ? available_units_from_subs : []
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/sources/tests/result'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Sources
|
8
|
+
module Tests
|
9
|
+
class Performer
|
10
|
+
enable_simple_cache
|
11
|
+
|
12
|
+
common_constructor(:owner)
|
13
|
+
|
14
|
+
def non_failed_units
|
15
|
+
units.reject(&:failed?)
|
16
|
+
end
|
17
|
+
|
18
|
+
def failed_units
|
19
|
+
units.select(&:failed?)
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Boolean]
|
23
|
+
def successful?
|
24
|
+
failed_units.none?
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def units_uncached
|
30
|
+
owner.selected_units
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/sources/tests/result'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/fs/logs'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Sources
|
9
|
+
module Tests
|
10
|
+
class Single
|
11
|
+
MAIN_SOURCE_ID = '#main'
|
12
|
+
|
13
|
+
compare_by :order_group, :id
|
14
|
+
enable_simple_cache
|
15
|
+
enable_speaker
|
16
|
+
|
17
|
+
common_constructor :builder, :source
|
18
|
+
|
19
|
+
delegate :logs, :result, to: :tester
|
20
|
+
delegate :to_s, to: :id
|
21
|
+
|
22
|
+
def failed?
|
23
|
+
result == ::Avm::Sources::Tests::Result::FAILED
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [String]
|
27
|
+
def id
|
28
|
+
if main?
|
29
|
+
MAIN_SOURCE_ID
|
30
|
+
else
|
31
|
+
relative_path_from_main_source.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def main?
|
36
|
+
relative_path_from_main_source.to_s == '.'
|
37
|
+
end
|
38
|
+
|
39
|
+
def order_group
|
40
|
+
main? ? 1 : 0
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Pathname]
|
44
|
+
def relative_path_from_main_source
|
45
|
+
source.path.relative_path_from(builder.main_source.path)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def tester_uncached
|
51
|
+
source.tester
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/avm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo H. Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_cli
|
@@ -234,12 +234,19 @@ files:
|
|
234
234
|
- lib/avm/self/instance.rb
|
235
235
|
- lib/avm/self/instance/entry_keys.rb
|
236
236
|
- lib/avm/source_stereotypes/base.rb
|
237
|
+
- lib/avm/source_stereotypes/tester.rb
|
237
238
|
- lib/avm/sources.rb
|
238
239
|
- lib/avm/sources/base.rb
|
240
|
+
- lib/avm/sources/base/configuration.rb
|
239
241
|
- lib/avm/sources/configuration.rb
|
240
242
|
- lib/avm/sources/configuration/_locale.rb
|
241
243
|
- lib/avm/sources/configuration/_rubocop.rb
|
242
244
|
- lib/avm/sources/configuration/_tests.rb
|
245
|
+
- lib/avm/sources/tests.rb
|
246
|
+
- lib/avm/sources/tests/builder.rb
|
247
|
+
- lib/avm/sources/tests/performer.rb
|
248
|
+
- lib/avm/sources/tests/result.rb
|
249
|
+
- lib/avm/sources/tests/single.rb
|
243
250
|
- lib/avm/sync.rb
|
244
251
|
- lib/avm/version.rb
|
245
252
|
- lib/avm/version_number.rb
|