avm 0.23.0 → 0.24.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 +4 -4
- data/lib/avm/sources/base/configuration.rb +14 -6
- data/lib/avm/sources/base/testing.rb +50 -7
- data/lib/avm/sources/tests/builder.rb +8 -1
- data/lib/avm/sources/tests/single.rb +28 -9
- data/lib/avm/version.rb +1 -1
- metadata +2 -3
- data/lib/avm/sources/tester.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 937c532ad108fabe2301a9e6a32048f0f0d8afd771d384d7079650c09a96f9c4
|
4
|
+
data.tar.gz: f76e3a10f12fa40c99bc1374039133f544e7d8757e771b581b27f5e85029c46e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9e645ab258c0a24d70cde2b6ba74e0af37f1fd3d8c1390e60416862b9d6cb47b8c109776243da88447204a0bb13c90ab9ea3c27aa7dddd93cb9814aa0829ee
|
7
|
+
data.tar.gz: 8bf8b0fe97dd546a96af5abb7124d7740b66f1ce585613589281bee8aadb81075e7a0c8a305ae81e2dc7e50c2aa31ed1a3401cae7804664dfe592929fbb357b2
|
@@ -11,19 +11,27 @@ module Avm
|
|
11
11
|
module Configuration
|
12
12
|
CONFIGURATION_FILENAMES = %w[.avm.yml .avm.yaml].freeze
|
13
13
|
|
14
|
+
# @return [EacRubyUtils::Envs::Command, nil]
|
15
|
+
def configuration_value_to_env_command(value)
|
16
|
+
configuration_value_to_shell_words(value).if_present { |v| env.command(v).chdir(path) }
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Array<String>, nil]
|
20
|
+
def configuration_value_to_shell_words(value)
|
21
|
+
return nil if value.blank?
|
22
|
+
|
23
|
+
value.is_a?(::Enumerable) ? value.map(&:to_s) : ::Shellwords.split(value.to_s)
|
24
|
+
end
|
25
|
+
|
14
26
|
# @return [Array<String>, nil]
|
15
27
|
def read_configuration_as_shell_words(key)
|
16
|
-
configuration.entry(key).value
|
17
|
-
v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v.to_s)
|
18
|
-
end
|
28
|
+
configuration_value_to_shell_words(configuration.entry(key).value)
|
19
29
|
end
|
20
30
|
|
21
31
|
# Utility to read a configuration as a [EacRubyUtils::Envs::Command].
|
22
32
|
# @return [EacRubyUtils::Envs::Command]
|
23
33
|
def read_configuration_as_env_command(key)
|
24
|
-
|
25
|
-
env.command(v).chdir(path)
|
26
|
-
end
|
34
|
+
configuration_value_to_env_command(configuration.entry(key).value)
|
27
35
|
end
|
28
36
|
|
29
37
|
private
|
@@ -1,25 +1,68 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/envs/command'
|
4
5
|
|
5
6
|
module Avm
|
6
7
|
module Sources
|
7
8
|
class Base
|
8
9
|
module Testing
|
9
|
-
|
10
|
+
DEFAULT_TEST_COMMANDS = {}.freeze
|
11
|
+
TEST_KEY = 'test'
|
12
|
+
TEST_COMMAND_KEY = "#{TEST_KEY}.command"
|
13
|
+
TEST_COMMANDS_KEY = "#{TEST_KEY}.commands"
|
10
14
|
|
11
15
|
def configured_test_command
|
12
16
|
read_configuration_as_env_command(TEST_COMMAND_KEY)
|
13
17
|
end
|
14
18
|
|
15
|
-
# @return [
|
16
|
-
def
|
17
|
-
|
19
|
+
# @return [Hash<String, EacRubyUtils::Envs::Command>, nil]
|
20
|
+
def configured_test_commands
|
21
|
+
configured_value_as_test_commands(configuration.entry(TEST_COMMANDS_KEY).value)
|
18
22
|
end
|
19
23
|
|
20
|
-
# @return [
|
21
|
-
def
|
22
|
-
|
24
|
+
# @return [Hash<String, EacRubyUtils::Envs::Command>, nil]
|
25
|
+
def configured_value_as_test_commands(value)
|
26
|
+
return nil if value.blank?
|
27
|
+
|
28
|
+
[::EacRubyUtils::Envs::Command, ::Hash, ::Enumerable].each do |type|
|
29
|
+
next unless value.is_a?(type)
|
30
|
+
|
31
|
+
return send(
|
32
|
+
"configured_#{type.name.demodulize.variableize}_value_as_test_commands",
|
33
|
+
value
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
raise "Value for test commands should be a Hash or a Enumerable (Actual: #{value})"
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Hash<String, EacRubyUtils::Envs::Command>]
|
41
|
+
def default_test_commands
|
42
|
+
DEFAULT_TEST_COMMANDS
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [Enumerable<EacRubyUtils::Envs::Command>]
|
46
|
+
def test_commands
|
47
|
+
configured_test_commands ||
|
48
|
+
configured_value_as_test_commands(configured_test_command)
|
49
|
+
default_test_commands
|
50
|
+
end
|
51
|
+
|
52
|
+
protected
|
53
|
+
|
54
|
+
def configured_command_value_as_test_commands(value)
|
55
|
+
configured_enumerable_value_as_test_commands([value])
|
56
|
+
end
|
57
|
+
|
58
|
+
def configured_enumerable_value_as_test_commands(value)
|
59
|
+
configured_hash_value_as_test_commands(
|
60
|
+
value.each_with_index.map { |v| ["test_#{v[1]}", v[0]] }.to_h
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def configured_hash_value_as_test_commands(value)
|
65
|
+
value.map { |k, v| [k.to_s.strip, configuration_value_to_env_command(v)] }.to_h
|
23
66
|
end
|
24
67
|
end
|
25
68
|
end
|
@@ -44,6 +44,13 @@ module Avm
|
|
44
44
|
create_units(main_source.subs)
|
45
45
|
end
|
46
46
|
|
47
|
+
# @return [Array<Avm::Sources::Tests::Single>]
|
48
|
+
def create_source_units(source)
|
49
|
+
source.test_commands.map do |test_name, test_command|
|
50
|
+
::Avm::Sources::Tests::Single.new(self, source, test_name, test_command)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
47
54
|
# @return [Avm::Sources::Tests::Single]
|
48
55
|
def create_unit(source)
|
49
56
|
::Avm::Sources::Tests::Single.new(self, source)
|
@@ -51,7 +58,7 @@ module Avm
|
|
51
58
|
|
52
59
|
# @return [Array<Avm::Sources::Tests::Single>]
|
53
60
|
def create_units(sources)
|
54
|
-
sources.
|
61
|
+
sources.flat_map { |a_source| create_source_units(a_source) }
|
55
62
|
end
|
56
63
|
|
57
64
|
# @return [Avm::Sources::Tests::Single]
|
@@ -14,9 +14,8 @@ module Avm
|
|
14
14
|
enable_simple_cache
|
15
15
|
enable_speaker
|
16
16
|
|
17
|
-
common_constructor :builder, :source
|
17
|
+
common_constructor :builder, :source, :test_name, :test_command
|
18
18
|
|
19
|
-
delegate :logs, :result, to: :tester
|
20
19
|
delegate :to_s, to: :id
|
21
20
|
|
22
21
|
def failed?
|
@@ -25,11 +24,7 @@ module Avm
|
|
25
24
|
|
26
25
|
# @return [String]
|
27
26
|
def id
|
28
|
-
|
29
|
-
MAIN_SOURCE_ID
|
30
|
-
else
|
31
|
-
relative_path_from_main_source.to_s
|
32
|
-
end
|
27
|
+
"#{main? ? MAIN_SOURCE_ID : relative_path_from_main_source}\##{test_name}"
|
33
28
|
end
|
34
29
|
|
35
30
|
def main?
|
@@ -47,8 +42,32 @@ module Avm
|
|
47
42
|
|
48
43
|
private
|
49
44
|
|
50
|
-
|
51
|
-
|
45
|
+
# @return [EacFs::Logs]
|
46
|
+
def logs_uncached
|
47
|
+
::EacFs::Logs.new.add(:stdout).add(:stderr)
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Avm::Sources::Tests::Result]
|
51
|
+
def result_uncached
|
52
|
+
if test_command.blank?
|
53
|
+
::Avm::Sources::Tests::Result::NONEXISTENT
|
54
|
+
elsif run_test_command
|
55
|
+
::Avm::Sources::Tests::Result::SUCESSFUL
|
56
|
+
else
|
57
|
+
::Avm::Sources::Tests::Result::FAILED
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def run_test_command
|
62
|
+
execute_command_and_log(test_command)
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [true, false]
|
66
|
+
def execute_command_and_log(command)
|
67
|
+
r = command.execute
|
68
|
+
logs[:stdout].write(r[:stdout])
|
69
|
+
logs[:stderr].write(r[:stderr])
|
70
|
+
r[:exit_code].zero?
|
52
71
|
end
|
53
72
|
end
|
54
73
|
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.24.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: 2022-07-
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_cli
|
@@ -252,7 +252,6 @@ files:
|
|
252
252
|
- lib/avm/sources/base/testing.rb
|
253
253
|
- lib/avm/sources/configuration.rb
|
254
254
|
- lib/avm/sources/configuration/rubocop.rb
|
255
|
-
- lib/avm/sources/tester.rb
|
256
255
|
- lib/avm/sources/tests.rb
|
257
256
|
- lib/avm/sources/tests/builder.rb
|
258
257
|
- lib/avm/sources/tests/performer.rb
|
data/lib/avm/sources/tester.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module Avm
|
6
|
-
module Sources
|
7
|
-
class Tester
|
8
|
-
enable_abstract_methods
|
9
|
-
common_constructor :source
|
10
|
-
|
11
|
-
abstract_methods :result, :logs
|
12
|
-
|
13
|
-
# @return [EacFs::Logs]
|
14
|
-
def logs
|
15
|
-
raise_abstract_method __method__
|
16
|
-
end
|
17
|
-
|
18
|
-
# @return [Avm::Sources::Tests::Result]
|
19
|
-
def result
|
20
|
-
raise_abstract_method __method__
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|