polytrix 0.0.1 → 0.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.rspec +1 -6
- data/.rubocop-todo.yml +19 -0
- data/.rubocop.yml +10 -0
- data/.travis.yml +11 -0
- data/Gemfile +0 -16
- data/README.md +119 -28
- data/Rakefile +18 -123
- data/bin/polytrix +5 -0
- data/doc-src/_markdown.md +5 -0
- data/doc-src/default_bootstrap.md +13 -0
- data/docs/influences.md +28 -0
- data/docs/samples/code2doc/java/HelloWorld.md +13 -0
- data/docs/samples/code2doc/java/Quine.md +33 -0
- data/docs/samples/code2doc/python/hello_world.md +3 -0
- data/docs/samples/code2doc/python/quine.md +4 -0
- data/docs/samples/code2doc/ruby/hello_world.md +7 -0
- data/features/execution.feature +67 -0
- data/features/fixtures/configs/empty.yml +12 -0
- data/features/fixtures/configs/hello_world.yml +10 -0
- data/features/fixtures/spec/polytrix_merge.rb +5 -0
- data/features/fixtures/spec/polytrix_spec.rb +10 -0
- data/features/reporting.feature +140 -0
- data/features/step_definitions/sdk_steps.rb +12 -0
- data/features/support/env.rb +8 -0
- data/lib/polytrix/challenge.rb +20 -7
- data/lib/polytrix/challenge_runner.rb +9 -44
- data/lib/polytrix/cli/add.rb +67 -0
- data/lib/polytrix/cli/report.rb +88 -0
- data/lib/polytrix/cli/reports/hash_reporter.rb +30 -0
- data/lib/polytrix/cli/reports/json_reporter.rb +14 -0
- data/lib/polytrix/cli/reports/markdown_reporter.rb +23 -0
- data/lib/polytrix/cli/reports/yaml_reporter.rb +14 -0
- data/lib/polytrix/cli.rb +158 -0
- data/lib/polytrix/configuration.rb +65 -4
- data/lib/polytrix/core/file_system_helper.rb +75 -0
- data/lib/polytrix/core/implementor.rb +31 -3
- data/lib/polytrix/documentation/code_segmenter.rb +168 -0
- data/lib/polytrix/documentation/comment_styles.rb +87 -0
- data/lib/polytrix/documentation/helpers/code_helper.rb +85 -0
- data/lib/polytrix/documentation/view_helper.rb +21 -0
- data/lib/polytrix/documentation_generator.rb +59 -10
- data/lib/polytrix/executor.rb +89 -0
- data/lib/polytrix/logger.rb +17 -0
- data/lib/polytrix/manifest.rb +64 -7
- data/lib/polytrix/result.rb +16 -2
- data/lib/polytrix/rspec/documentation_formatter.rb +41 -16
- data/lib/polytrix/rspec/yaml_report.rb +51 -0
- data/lib/polytrix/rspec.rb +32 -53
- data/lib/polytrix/runners/middleware/feature_executor.rb +4 -3
- data/lib/polytrix/runners/middleware/setup_env_vars.rb +6 -4
- data/lib/polytrix/validation.rb +20 -0
- data/lib/polytrix/validations.rb +23 -0
- data/lib/polytrix/validator.rb +20 -0
- data/lib/polytrix/validator_registry.rb +34 -0
- data/lib/polytrix/version.rb +1 -1
- data/lib/polytrix.rb +125 -22
- data/polytrix.gemspec +7 -2
- data/polytrix.rb +6 -0
- data/polytrix_tests.yml +20 -0
- data/resources/code_sample.tt +2 -0
- data/samples/.gitignore +2 -0
- data/samples/_markdown.md +5 -0
- data/samples/default_bootstrap.rb +14 -0
- data/samples/polytrix.rb +28 -0
- data/samples/polytrix_cli.sh +7 -0
- data/samples/polytrix_tests.yml +10 -0
- data/{sdks/fog → samples}/scripts/bootstrap +0 -2
- data/samples/scripts/wrapper +7 -0
- data/samples/sdks/custom/polytrix.yml +2 -0
- data/samples/sdks/java/.gitignore +2 -0
- data/samples/sdks/java/build.gradle +14 -0
- data/samples/sdks/java/challenges/HelloWorld.java +10 -0
- data/samples/sdks/java/challenges/Quine.java +31 -0
- data/samples/sdks/java/code_sample.tt +11 -0
- data/samples/sdks/java/scripts/bootstrap +2 -0
- data/samples/sdks/java/scripts/wrapper +8 -0
- data/samples/sdks/python/challenges/hello_world.py +2 -0
- data/samples/sdks/python/challenges/quine.py +2 -0
- data/{sdks/pkgcloud → samples/sdks/python}/scripts/wrapper +1 -1
- data/samples/sdks/ruby/challenges/hello_world.rb +4 -0
- data/scripts/bootstrap +1 -9
- data/scripts/wrapper +7 -0
- data/spec/fabricators/challenge_fabricator.rb +17 -0
- data/spec/fabricators/manifest_fabricator.rb +50 -0
- data/spec/fabricators/validator_fabricator.rb +12 -0
- data/spec/fixtures/{polytrix.yml → polytrix_tests.yml} +0 -0
- data/spec/fixtures/src-doc/_scenario.md.erb +1 -0
- data/spec/polytrix/challenge_runner_spec.rb +3 -3
- data/spec/polytrix/challenge_spec.rb +3 -4
- data/spec/polytrix/cli_spec.rb +39 -0
- data/spec/polytrix/configuration_spec.rb +45 -1
- data/spec/polytrix/documentation/helpers/code_helper_spec.rb +120 -0
- data/spec/polytrix/documentation_generator_spec.rb +41 -20
- data/spec/polytrix/file_finder_spec.rb +4 -3
- data/spec/polytrix/implementor_spec.rb +33 -0
- data/spec/polytrix/manifest_spec.rb +32 -14
- data/spec/polytrix/middleware/feature_executor_spec.rb +1 -1
- data/spec/polytrix/result_spec.rb +49 -0
- data/spec/polytrix/validations_spec.rb +16 -0
- data/spec/polytrix/validator_registry_spec.rb +39 -0
- data/spec/polytrix/validator_spec.rb +63 -0
- data/spec/polytrix_spec.rb +33 -7
- data/spec/spec_helper.rb +14 -1
- data/spec/thor_spy.rb +64 -0
- metadata +177 -160
- data/.rspec_parallel +0 -10
- data/Vagrantfile +0 -41
- data/features/0_identity_spec.rb +0 -40
- data/features/1_cloud_files_spec.rb +0 -48
- data/features/2_servers_spec.rb +0 -19
- data/features/features_helper.rb +0 -46
- data/features/helpers/cloudfiles_helper.rb +0 -31
- data/features/helpers/pacto_helper.rb +0 -33
- data/features/helpers/teardown_helper.rb +0 -49
- data/features/pacto/extensions/loaders/api_blueprint_loader.rb +0 -63
- data/features/pacto/extensions/loaders/simple_loader.rb +0 -55
- data/features/pacto/extensions/loaders/yaml_or_json_loader.rb +0 -17
- data/features/pacto/extensions/matchers.rb +0 -38
- data/features/phase2/feature_coverage_report.rb +0 -109
- data/features/phase2/run_all_features.rb +0 -14
- data/features/static_site/fixtures/index.html +0 -6
- data/lib/polytrix/challenge_builder.rb +0 -16
- data/lib/polytrix/core/file_finder.rb +0 -43
- data/lib/polytrix/core/result_tracker.rb +0 -25
- data/lib/polytrix/runners/middleware/pacto.rb +0 -59
- data/packer/.gitignore +0 -3
- data/packer/Berksfile +0 -15
- data/packer/Gemfile +0 -5
- data/packer/Vagrantfile +0 -128
- data/packer/cookbooks/drg/metadata.rb +0 -27
- data/packer/cookbooks/drg/recipes/admins.rb +0 -22
- data/packer/cookbooks/drg/recipes/default.rb +0 -9
- data/packer/cookbooks/drg/recipes/dotnet.rb +0 -4
- data/packer/cookbooks/drg/recipes/golang.rb +0 -4
- data/packer/cookbooks/drg/recipes/java.rb +0 -5
- data/packer/cookbooks/drg/recipes/php.rb +0 -10
- data/packer/cookbooks/drg/recipes/ruby.rb +0 -29
- data/packer/cookbooks/drg/recipes/system.rb +0 -13
- data/packer/create_box.sh +0 -10
- data/packer/http/preseed.cfg +0 -87
- data/packer/packer.json +0 -91
- data/packer/scripts/root_setup.sh +0 -37
- data/packer/scripts/setup.sh +0 -32
- data/pacto/config/pacto_server.rb +0 -40
- data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/extensions.json +0 -64
- data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/flavors/id.json +0 -100
- data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/images/id.json +0 -176
- data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers/id.json +0 -189
- data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers.json +0 -63
- data/pacto/contracts/dns.api.rackspacecloud.com/v1.0/_tenant_id/domains.json +0 -62
- data/pacto/contracts/identity.api.rackspacecloud.com/v2.0/tokens.json +0 -192
- data/pacto/contracts/monitoring.api.rackspacecloud.com/v1.0/_tenant_id/account.json +0 -39
- data/pacto/contracts/ord.autoscale.api.rackspacecloud.com/v1.0/_tenant_id/groups.json +0 -38
- data/pacto/contracts/ord.blockstorage.api.rackspacecloud.com/v1/_tenant_id/volumes.json +0 -30
- data/pacto/contracts/ord.databases.api.rackspacecloud.com/v1.0/_tenant_id/instances.json +0 -30
- data/pacto/contracts/ord.loadbalancers.api.rackspacecloud.com/v1.0/_tenant_id/loadbalancers.json +0 -114
- data/pacto/contracts/ord.queues.api.rackspacecloud.com/v1/_tenant_id/queues.json +0 -13
- data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/os-networksv2.json +0 -46
- data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/servers/detail.json +0 -230
- data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account/container/object.json +0 -15
- data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account.json +0 -43
- data/pacto/contracts/storage101.ord1.clouddrive.com/v1/_mosso_id.json +0 -44
- data/pacto/pacto_server.rb +0 -100
- data/pacto/rackspace_uri_map.yaml +0 -229
- data/scripts/cibuild +0 -4
- data/sdks/fog/.gitignore +0 -1
- data/sdks/fog/Gemfile +0 -5
- data/sdks/fog/challenges/all_connections.rb +0 -45
- data/sdks/fog/challenges/authenticate_token.rb +0 -15
- data/sdks/fog/challenges/cdn_enable_container.rb +0 -20
- data/sdks/fog/challenges/create_a_container.rb +0 -17
- data/sdks/fog/challenges/create_server.rb +0 -36
- data/sdks/fog/challenges/get_object_metadata.rb +0 -13
- data/sdks/fog/challenges/list_containers.rb +0 -10
- data/sdks/fog/challenges/provision_scalable_webapp.rb +0 -30
- data/sdks/fog/challenges/upload_folder.rb +0 -25
- data/sdks/fog/scripts/bootstrap.ps1 +0 -1
- data/sdks/fog/scripts/wrapper +0 -2
- data/sdks/fog/scripts/wrapper.ps1 +0 -1
- data/sdks/gophercloud/.gitignore +0 -2
- data/sdks/gophercloud/challenges/authenticate_token.go +0 -23
- data/sdks/gophercloud/scripts/bootstrap +0 -6
- data/sdks/gophercloud/scripts/wrapper +0 -10
- data/sdks/jclouds/.gitignore +0 -1
- data/sdks/jclouds/challenges/AuthenticateToken.java +0 -115
- data/sdks/jclouds/pom.xml +0 -34
- data/sdks/jclouds/scripts/bootstrap +0 -3
- data/sdks/jclouds/scripts/wrapper +0 -7
- data/sdks/openstack.net/.gitignore +0 -4
- data/sdks/openstack.net/.nuget/Microsoft.Build.dll +0 -0
- data/sdks/openstack.net/.nuget/NuGet.Config +0 -6
- data/sdks/openstack.net/.nuget/NuGet.exe +0 -0
- data/sdks/openstack.net/.nuget/NuGet.targets +0 -136
- data/sdks/openstack.net/Challenge.cs +0 -10
- data/sdks/openstack.net/RunChallenge.cs +0 -19
- data/sdks/openstack.net/challenges/AuthenticateToken.cs +0 -24
- data/sdks/openstack.net/challenges/Weird.cs +0 -133
- data/sdks/openstack.net/openstack.net.csproj +0 -58
- data/sdks/openstack.net/openstack.net.sln +0 -27
- data/sdks/openstack.net/openstack.net.userprefs +0 -8
- data/sdks/openstack.net/packages.config +0 -6
- data/sdks/openstack.net/scripts/bootstrap +0 -2
- data/sdks/openstack.net/scripts/bootstrap.ps1 +0 -2
- data/sdks/openstack.net/scripts/wrapper +0 -7
- data/sdks/openstack.net/scripts/wrapper.ps1 +0 -1
- data/sdks/php-opencloud/.gitignore +0 -4
- data/sdks/php-opencloud/challenges/all_connections.php +0 -64
- data/sdks/php-opencloud/challenges/authenticate_token.php +0 -14
- data/sdks/php-opencloud/challenges/create_server.php +0 -39
- data/sdks/php-opencloud/challenges/get_object_metadata.php +0 -19
- data/sdks/php-opencloud/composer.json +0 -5
- data/sdks/php-opencloud/scripts/bootstrap +0 -4
- data/sdks/php-opencloud/scripts/bootstrap.ps1 +0 -2
- data/sdks/php-opencloud/scripts/wrapper +0 -2
- data/sdks/php-opencloud/scripts/wrapper.ps1 +0 -1
- data/sdks/pkgcloud/.gitignore +0 -1
- data/sdks/pkgcloud/challenges/authenticate_token.js +0 -17
- data/sdks/pkgcloud/challenges/get_object_metadata.js +0 -18
- data/sdks/pkgcloud/scripts/bootstrap +0 -2
- data/sdks/pkgcloud/scripts/bootstrap.ps1 +0 -1
- data/sdks/pkgcloud/scripts/wrapper.ps1 +0 -1
- data/sdks/pyrax/.gitignore +0 -2
- data/sdks/pyrax/challenges/all_connections.py +0 -61
- data/sdks/pyrax/challenges/authenticate_token.py +0 -17
- data/sdks/pyrax/challenges/cdn_enable_container.py +0 -22
- data/sdks/pyrax/challenges/create_a_container.py +0 -21
- data/sdks/pyrax/challenges/create_server.py +0 -35
- data/sdks/pyrax/challenges/get_object_metadata.py +0 -17
- data/sdks/pyrax/challenges/upload_folder.py +0 -32
- data/sdks/pyrax/requirements.txt +0 -21
- data/sdks/pyrax/scripts/bootstrap +0 -9
- data/sdks/pyrax/scripts/bootstrap.ps1 +0 -7
- data/sdks/pyrax/scripts/wrapper +0 -3
- data/sdks/pyrax/scripts/wrapper.ps1 +0 -2
- data/spec/polytrix/challenge_builder_spec.rb +0 -16
- data/spec/rspec_spec.rb +0 -17
@@ -0,0 +1,140 @@
|
|
1
|
+
Feature: Reporting
|
2
|
+
|
3
|
+
Polytrix creates YAML reports on teach test run. The reports are designed to be "deep mergable", so that you can split a test suite into separate threads running in parallel, each generating a separate report, and then merge them all to create a combined report.
|
4
|
+
|
5
|
+
Scenario: A report for a single SDK
|
6
|
+
Given the ruby SDK
|
7
|
+
And the hello_world polytrix config
|
8
|
+
And the standard rspec setup
|
9
|
+
When I successfully run `bundle exec rspec -f Polytrix::RSpec::YAMLReport -o reports/polytrix.yaml`
|
10
|
+
Then the file "reports/polytrix.yaml" should contain exactly:
|
11
|
+
"""
|
12
|
+
---
|
13
|
+
global_env:
|
14
|
+
LOCALE: en_US.UTF-8
|
15
|
+
FAVORITE_NUMBER: '5'
|
16
|
+
suites:
|
17
|
+
Katas:
|
18
|
+
env:
|
19
|
+
NAME: Max
|
20
|
+
samples:
|
21
|
+
hello world:
|
22
|
+
ruby:
|
23
|
+
validations:
|
24
|
+
- validated_by: polytrix
|
25
|
+
result: passed
|
26
|
+
execution_result:
|
27
|
+
exitstatus: 0
|
28
|
+
stdout: |
|
29
|
+
Hello, world!
|
30
|
+
stderr: ''
|
31
|
+
source_file: challenges/hello_world.rb
|
32
|
+
|
33
|
+
"""
|
34
|
+
|
35
|
+
Scenario: A report for several SDKS
|
36
|
+
Given the ruby SDK
|
37
|
+
And the java SDK
|
38
|
+
And the python SDK
|
39
|
+
And the hello_world polytrix config
|
40
|
+
And the standard rspec setup
|
41
|
+
When I successfully run `bundle exec rspec -f Polytrix::RSpec::YAMLReport -o reports/polytrix.yaml`
|
42
|
+
Then the file "reports/polytrix.yaml" should contain exactly:
|
43
|
+
"""
|
44
|
+
---
|
45
|
+
global_env:
|
46
|
+
LOCALE: en_US.UTF-8
|
47
|
+
FAVORITE_NUMBER: '5'
|
48
|
+
suites:
|
49
|
+
Katas:
|
50
|
+
env:
|
51
|
+
NAME: Max
|
52
|
+
samples:
|
53
|
+
hello world:
|
54
|
+
java:
|
55
|
+
validations:
|
56
|
+
- validated_by: polytrix
|
57
|
+
result: passed
|
58
|
+
execution_result:
|
59
|
+
exitstatus: 0
|
60
|
+
stdout: |
|
61
|
+
Hello, world!
|
62
|
+
stderr: ''
|
63
|
+
source_file: challenges/HelloWorld.java
|
64
|
+
python:
|
65
|
+
validations:
|
66
|
+
- validated_by: polytrix
|
67
|
+
result: passed
|
68
|
+
execution_result:
|
69
|
+
exitstatus: 0
|
70
|
+
stdout: |
|
71
|
+
Hello, world!
|
72
|
+
stderr: ''
|
73
|
+
source_file: challenges/hello_world.py
|
74
|
+
ruby:
|
75
|
+
validations:
|
76
|
+
- validated_by: polytrix
|
77
|
+
result: passed
|
78
|
+
execution_result:
|
79
|
+
exitstatus: 0
|
80
|
+
stdout: |
|
81
|
+
Hello, world!
|
82
|
+
stderr: ''
|
83
|
+
source_file: challenges/hello_world.rb
|
84
|
+
|
85
|
+
"""
|
86
|
+
|
87
|
+
Scenario: Merging separate reports
|
88
|
+
Given the ruby SDK
|
89
|
+
And the java SDK
|
90
|
+
And the python SDK
|
91
|
+
And the hello_world polytrix config
|
92
|
+
And the standard rspec setup
|
93
|
+
When I successfully run `bundle exec rspec -f Polytrix::RSpec::YAMLReport -t ruby -o reports/polytrix-ruby.yaml`
|
94
|
+
When I successfully run `bundle exec rspec -f Polytrix::RSpec::YAMLReport -t java -o reports/polytrix-java.yaml`
|
95
|
+
When I successfully run `bundle exec rspec -f Polytrix::RSpec::YAMLReport -t python -o reports/polytrix-python.yaml`
|
96
|
+
And I successfully run `bundle exec ruby spec/polytrix_merge.rb reports/polytrix-java.yaml reports/polytrix-python.yaml reports/polytrix-ruby.yaml`
|
97
|
+
Then the file "reports/polytrix.yaml" should contain exactly:
|
98
|
+
"""
|
99
|
+
---
|
100
|
+
global_env:
|
101
|
+
LOCALE: en_US.UTF-8
|
102
|
+
FAVORITE_NUMBER: '5'
|
103
|
+
suites:
|
104
|
+
Katas:
|
105
|
+
env:
|
106
|
+
NAME: Max
|
107
|
+
samples:
|
108
|
+
hello world:
|
109
|
+
java:
|
110
|
+
validations:
|
111
|
+
- validated_by: polytrix
|
112
|
+
result: passed
|
113
|
+
execution_result:
|
114
|
+
exitstatus: 0
|
115
|
+
stdout: |
|
116
|
+
Hello, world!
|
117
|
+
stderr: ''
|
118
|
+
source_file: challenges/HelloWorld.java
|
119
|
+
python:
|
120
|
+
validations:
|
121
|
+
- validated_by: polytrix
|
122
|
+
result: passed
|
123
|
+
execution_result:
|
124
|
+
exitstatus: 0
|
125
|
+
stdout: |
|
126
|
+
Hello, world!
|
127
|
+
stderr: ''
|
128
|
+
source_file: challenges/hello_world.py
|
129
|
+
ruby:
|
130
|
+
validations:
|
131
|
+
- validated_by: polytrix
|
132
|
+
result: passed
|
133
|
+
execution_result:
|
134
|
+
exitstatus: 0
|
135
|
+
stdout: |
|
136
|
+
Hello, world!
|
137
|
+
stderr: ''
|
138
|
+
source_file: challenges/hello_world.rb
|
139
|
+
|
140
|
+
"""
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Given(/^the (\w+) SDK$/) do |sdk|
|
2
|
+
FileUtils.mkdir_p "#{current_dir}/sdks"
|
3
|
+
FileUtils.cp_r "samples/sdks/#{sdk}", "#{current_dir}/sdks"
|
4
|
+
end
|
5
|
+
|
6
|
+
Given(/^the (\w+) polytrix config$/) do |config|
|
7
|
+
FileUtils.cp_r "features/fixtures/configs/#{config}.yml", "#{current_dir}/polytrix_tests.yml"
|
8
|
+
end
|
9
|
+
|
10
|
+
Given(/^the standard rspec setup$/) do
|
11
|
+
FileUtils.cp_r 'features/fixtures/spec/', "#{current_dir}/"
|
12
|
+
end
|
data/lib/polytrix/challenge.rb
CHANGED
@@ -1,27 +1,40 @@
|
|
1
1
|
require 'hashie/dash'
|
2
2
|
require 'hashie/extensions/coercion'
|
3
3
|
require 'hashie/extensions/indifferent_access'
|
4
|
+
require 'polytrix/documentation/helpers/code_helper'
|
4
5
|
|
5
6
|
module Polytrix
|
6
7
|
class Challenge < Hashie::Dash
|
7
8
|
include Hashie::Extensions::Coercion
|
8
|
-
|
9
|
+
|
10
|
+
# View heleprs
|
11
|
+
include Polytrix::Documentation::Helpers::CodeHelper
|
12
|
+
|
9
13
|
property :name
|
14
|
+
property :description
|
10
15
|
property :implementor
|
11
|
-
property :
|
16
|
+
property :suite, required: true
|
17
|
+
property :vars, default: {}
|
12
18
|
property :source_file
|
13
19
|
coerce_key :source_file, Pathname
|
14
20
|
property :basedir
|
15
21
|
coerce_key :basedir, Pathname
|
16
|
-
property :challenge_runner, :
|
22
|
+
property :challenge_runner, default: ChallengeRunner.create_runner
|
17
23
|
property :result
|
18
24
|
property :env_file
|
19
|
-
coerce_key :vars, Polytrix::Manifest::Environment
|
20
|
-
property :plugin_data, :
|
25
|
+
# coerce_key :vars, Polytrix::Manifest::Environment
|
26
|
+
property :plugin_data, default: {}
|
21
27
|
|
22
28
|
def run
|
23
|
-
challenge_runner.run_challenge self
|
29
|
+
@result = challenge_runner.run_challenge self
|
24
30
|
end
|
25
31
|
|
32
|
+
def validate
|
33
|
+
run unless @result
|
34
|
+
# validators = Polytrix::ValidatorRegistry.validators_for self
|
35
|
+
# validators.each do |validator|
|
36
|
+
# validator.validate self
|
37
|
+
# end
|
38
|
+
end
|
26
39
|
end
|
27
|
-
end
|
40
|
+
end
|
@@ -8,16 +8,11 @@ module Polytrix
|
|
8
8
|
autoload :WindowsChallengeRunner, 'polytrix/runners/windows_challenge_runner'
|
9
9
|
end
|
10
10
|
|
11
|
-
class
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
11
|
+
class ChallengeRunner < Thor::Shell::Color
|
12
|
+
include Polytrix::Core::FileSystemHelper
|
13
|
+
include Polytrix::Executor
|
16
14
|
|
17
|
-
|
18
|
-
include Polytrix::Core::FileFinder
|
19
|
-
|
20
|
-
def self.createRunner
|
15
|
+
def self.create_runner
|
21
16
|
case RbConfig::CONFIG['host_os']
|
22
17
|
when /mswin(\d+)|mingw/i
|
23
18
|
Runners::WindowsChallengeRunner.new
|
@@ -34,23 +29,12 @@ module Polytrix
|
|
34
29
|
ENV['CHALLENGE_EDITOR']
|
35
30
|
end
|
36
31
|
|
37
|
-
def interactive?
|
38
|
-
ENV['INTERACTIVE']
|
39
|
-
end
|
40
|
-
|
41
|
-
def show_output?
|
42
|
-
ENV['SHOW_OUTPUT']
|
43
|
-
end
|
44
|
-
|
45
32
|
def run_command(command)
|
46
|
-
if
|
47
|
-
|
48
|
-
else
|
49
|
-
|
50
|
-
|
51
|
-
challenge_process.run_command
|
52
|
-
challenge_process.error!
|
53
|
-
challenge_process
|
33
|
+
if Polytrix.configuration.dry_run
|
34
|
+
puts "Would have run #{command}"
|
35
|
+
else
|
36
|
+
say_status 'polytrix:execute', command
|
37
|
+
execute command
|
54
38
|
end
|
55
39
|
end
|
56
40
|
|
@@ -59,25 +43,6 @@ module Polytrix
|
|
59
43
|
challenge
|
60
44
|
end
|
61
45
|
|
62
|
-
def find_challenge!(challenge, basedir = Dir.pwd)
|
63
|
-
find_file basedir, challenge
|
64
|
-
rescue Polytrix::Core::FileFinder::FileNotFound
|
65
|
-
raise FeatureNotImplementedError, challenge
|
66
|
-
end
|
67
|
-
|
68
|
-
def edit_challenge(challenge)
|
69
|
-
suffix = infer_suffix File.dirname(challenge)
|
70
|
-
challenge_file = "#{challenge}#{suffix}"
|
71
|
-
puts "Would you like to create #{challenge_file} (y/n)? "
|
72
|
-
system "#{challenge_editor} #{challenge_file}" if $stdin.gets.strip == 'y'
|
73
|
-
File.absolute_path challenge_file
|
74
|
-
end
|
75
|
-
|
76
|
-
def infer_suffix(source_dir)
|
77
|
-
# FIXME: Should be configurable or have a better way to infer
|
78
|
-
Dir["#{source_dir}/**/*.*"].map { |f| File.extname f }.first
|
79
|
-
end
|
80
|
-
|
81
46
|
private
|
82
47
|
|
83
48
|
def middleware
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Polytrix
|
2
|
+
module CLI
|
3
|
+
class Add < Polytrix::CLI::Base
|
4
|
+
include Thor::Actions
|
5
|
+
desc 'sample IMPLEMENTOR SCENARIO', 'Add a code sample for an implementor'
|
6
|
+
# sdk_options
|
7
|
+
method_option :language, type: 'string', desc: 'Programming language to use (if not already configured by the implementor)', default: 'rb'
|
8
|
+
def sample(implementor, scenario)
|
9
|
+
# implementor = pick_implementor(options[:sdk])
|
10
|
+
implementor = pick_implementor implementor
|
11
|
+
language = implementor.language || options[:language]
|
12
|
+
generate_source implementor, scenario, language
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
source_root Polytrix.configuration.template_dir
|
18
|
+
# source_root implementor.basedir
|
19
|
+
|
20
|
+
def generate_source(implementor, scenario, language)
|
21
|
+
source_paths.prepend File.expand_path(implementor.basedir)
|
22
|
+
@implementor = implementor
|
23
|
+
@scenario = implementor.build_challenge(
|
24
|
+
name: scenario
|
25
|
+
)
|
26
|
+
@language = language
|
27
|
+
|
28
|
+
output_file = File.join(implementor.basedir, "#{scenario.gsub(' ', '_')}.#{language}")
|
29
|
+
template('code_sample.tt', output_file)
|
30
|
+
end
|
31
|
+
|
32
|
+
def commented(comment)
|
33
|
+
return if comment.nil?
|
34
|
+
|
35
|
+
buffer = StringIO.new
|
36
|
+
_lang, comment_style = Polytrix::Documentation::CommentStyles.infer @language
|
37
|
+
if use_multiline? comment, comment_style
|
38
|
+
buffer.puts comment_style[:multi][:start]
|
39
|
+
comment.lines.each do |line|
|
40
|
+
buffer.puts comment_line(line, comment_style[:multi][:middle])
|
41
|
+
end
|
42
|
+
buffer.puts comment_style[:multi][:end]
|
43
|
+
else
|
44
|
+
comment.lines.each do |line|
|
45
|
+
buffer.puts comment_line(line, comment_style[:single])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
buffer.string
|
49
|
+
end
|
50
|
+
|
51
|
+
def comment_line(line, comment_string)
|
52
|
+
comment_string ||= ''
|
53
|
+
if line.strip.empty?
|
54
|
+
whitespace, line = line.gsub("\n", ''), ''
|
55
|
+
else
|
56
|
+
whitespace, line = line.rstrip.match(/([\s]*)(.*)/).captures
|
57
|
+
end
|
58
|
+
|
59
|
+
"#{whitespace}#{comment_string} #{line}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def use_multiline?(comment, comment_style)
|
63
|
+
comment.lines.size > 1 && !comment_style[:multi].nil? && (comment_style[:multi][:idiomatic] != false)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Polytrix
|
2
|
+
module CLI
|
3
|
+
module Reports
|
4
|
+
# autoload :TextReporter, 'polytrix/cli/reports/text_reporter'
|
5
|
+
autoload :MarkdownReporter, 'polytrix/cli/reports/markdown_reporter'
|
6
|
+
# autoload :HTMLReporter, 'polytrix/cli/reports/html_reporter'
|
7
|
+
autoload :JSONReporter, 'polytrix/cli/reports/json_reporter'
|
8
|
+
autoload :YAMLReporter, 'polytrix/cli/reports/yaml_reporter'
|
9
|
+
end
|
10
|
+
class Report < Polytrix::CLI::Base
|
11
|
+
# class_options = super.class_options
|
12
|
+
class_option :format, desc: 'Output format for the report', default: 'text', enum: %w(text markdown json yaml)
|
13
|
+
|
14
|
+
desc 'report summary', 'Generate a summary report by SDK'
|
15
|
+
config_options
|
16
|
+
log_options
|
17
|
+
def summary
|
18
|
+
setup
|
19
|
+
results = load_results
|
20
|
+
table = [%w(sdk passed failed pending skipped)]
|
21
|
+
results.each do |sdk, summary|
|
22
|
+
table << [sdk, summary[:passed], summary[:failed], summary[:pending], summary[:skipped]]
|
23
|
+
end
|
24
|
+
reporter.print_table table
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'report matrix', 'Generate a feature matrix report'
|
28
|
+
config_options
|
29
|
+
log_options
|
30
|
+
def matrix
|
31
|
+
setup
|
32
|
+
sdk_names = Polytrix.implementors.map(&:name)
|
33
|
+
table = [%w(Product Feature).concat(sdk_names)]
|
34
|
+
|
35
|
+
matrix_data.suites.each do |suite_name, suite_data|
|
36
|
+
suite_data.samples.each do |scenario_name, scenario_results|
|
37
|
+
|
38
|
+
statuses = sdk_names.map do |sdk|
|
39
|
+
result = Result.new(scenario_results[sdk])
|
40
|
+
result.status
|
41
|
+
end
|
42
|
+
|
43
|
+
table << [suite_name, scenario_name].concat(statuses)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
reporter.print_table table
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def matrix_data
|
52
|
+
@matrix ||= Polytrix::Manifest.new(YAML.load(Polytrix.merge_results(Dir['reports/test_report*.yaml'])))
|
53
|
+
end
|
54
|
+
|
55
|
+
def load_results
|
56
|
+
result_stats = Hash.new do |hash, sdk|
|
57
|
+
hash[sdk] = { passed: 0, failed: 0, pending: 0, skipped: 0 }
|
58
|
+
end
|
59
|
+
matrix_data.suites.reduce(result_stats) do |hash, (suite_name, suite)|
|
60
|
+
suite.samples.each do |sample, suite_results|
|
61
|
+
Polytrix.implementors.map(&:name).each do |sdk|
|
62
|
+
result = Result.new(suite_results[sdk])
|
63
|
+
result.validations << Validation.new(validated_by: 'polytrix', result: 'skipped')
|
64
|
+
hash[sdk][result.status.to_sym] += 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
hash
|
68
|
+
end
|
69
|
+
result_stats
|
70
|
+
end
|
71
|
+
|
72
|
+
def reporter
|
73
|
+
@reporter ||= case options[:format]
|
74
|
+
when 'text'
|
75
|
+
self
|
76
|
+
when 'markdown'
|
77
|
+
Polytrix::CLI::Reports::MarkdownReporter.new
|
78
|
+
when 'json'
|
79
|
+
Polytrix::CLI::Reports::JSONReporter.new
|
80
|
+
when 'yaml'
|
81
|
+
Polytrix::CLI::Reports::YAMLReporter.new
|
82
|
+
else
|
83
|
+
fail "Unknown report format #{options[:format]}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module Polytrix
|
4
|
+
module CLI
|
5
|
+
module Reports
|
6
|
+
class HashReporter
|
7
|
+
def initialize(io = $stdout)
|
8
|
+
@buffer = io
|
9
|
+
end
|
10
|
+
|
11
|
+
def print_table(table)
|
12
|
+
headers = table[0]
|
13
|
+
data = []
|
14
|
+
table[1..-1].map do |row|
|
15
|
+
row_data = {}
|
16
|
+
row.each_with_index do |value, index|
|
17
|
+
row_data[headers[index]] = value
|
18
|
+
end
|
19
|
+
data << row_data
|
20
|
+
end
|
21
|
+
@buffer.puts convert(data)
|
22
|
+
end
|
23
|
+
|
24
|
+
def convert(data)
|
25
|
+
fail 'Subclass HashReporter and convert the data to the target format'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Polytrix
|
2
|
+
module CLI
|
3
|
+
module Reports
|
4
|
+
class MarkdownReporter
|
5
|
+
def initialize(io = $stdout)
|
6
|
+
@buffer = io
|
7
|
+
end
|
8
|
+
|
9
|
+
def print_table(table)
|
10
|
+
@buffer.puts # Markdown tables don't always render properly without a break
|
11
|
+
header_data = table[0]
|
12
|
+
header_line = header_data.join ' | '
|
13
|
+
@buffer.puts header_line
|
14
|
+
@buffer.puts header_line.gsub(/[^|]/, '-')
|
15
|
+
|
16
|
+
table[1..-1].each do |data_line|
|
17
|
+
@buffer.puts data_line.join ' | '
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|