polytrix 0.1.0.pre → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +7 -2
  4. data/.travis.yml +2 -1
  5. data/Gemfile +1 -0
  6. data/README.md +190 -98
  7. data/Rakefile +8 -6
  8. data/bin/polytrix +2 -1
  9. data/docs/samples/code2doc/java/HelloWorld.md +4 -0
  10. data/docs/samples/code2doc/java/Quine.md +2 -0
  11. data/docs/samples/code2doc/python/hello_world.md +2 -0
  12. data/docs/samples/code2doc/python/quine.md +2 -0
  13. data/docs/samples/code2doc/ruby/hello_world.md +4 -0
  14. data/features/bootstrapping.feature +36 -0
  15. data/features/cloning.feature +34 -0
  16. data/features/execution.feature +2 -16
  17. data/features/fixtures/configs/empty.yml +12 -1
  18. data/features/fixtures/configs/hello_world.yml +11 -1
  19. data/features/fixtures/spec/polytrix_spec.rb +1 -4
  20. data/features/solo.feature +12 -0
  21. data/features/states.feature +40 -0
  22. data/features/step_definitions/sdk_steps.rb +11 -1
  23. data/features/support/env.rb +2 -1
  24. data/lib/polytrix/challenge.rb +211 -13
  25. data/lib/polytrix/challenge_result.rb +9 -0
  26. data/lib/polytrix/challenge_runner.rb +4 -11
  27. data/lib/polytrix/challenges.rb +16 -0
  28. data/lib/polytrix/cli/report.rb +0 -4
  29. data/lib/polytrix/cli.rb +229 -137
  30. data/lib/polytrix/color.rb +40 -0
  31. data/lib/polytrix/command/action.rb +26 -0
  32. data/lib/polytrix/command/list.rb +53 -0
  33. data/lib/polytrix/command/rundoc.rb +27 -0
  34. data/lib/polytrix/command/test.rb +24 -0
  35. data/lib/polytrix/command.rb +209 -0
  36. data/lib/polytrix/configuration.rb +30 -40
  37. data/lib/polytrix/core/file_system_helper.rb +2 -5
  38. data/lib/polytrix/core/hashie.rb +14 -0
  39. data/lib/polytrix/core/implementor.rb +52 -12
  40. data/lib/polytrix/core/manifest_section.rb +4 -0
  41. data/lib/polytrix/core/string_helpers.rb +15 -0
  42. data/lib/polytrix/documentation/helpers/code_helper.rb +3 -1
  43. data/lib/polytrix/error.rb +209 -0
  44. data/lib/polytrix/logger.rb +365 -8
  45. data/lib/polytrix/logging.rb +34 -0
  46. data/lib/polytrix/manifest.rb +40 -26
  47. data/lib/polytrix/result.rb +1 -0
  48. data/lib/polytrix/rspec.rb +7 -5
  49. data/lib/polytrix/runners/buff_shellout_executor.rb +19 -0
  50. data/lib/polytrix/runners/executor.rb +32 -0
  51. data/lib/polytrix/runners/mixlib_shellout_executor.rb +83 -0
  52. data/lib/polytrix/state_file.rb +60 -0
  53. data/lib/polytrix/util.rb +155 -0
  54. data/lib/polytrix/validation.rb +1 -1
  55. data/lib/polytrix/validator.rb +9 -5
  56. data/lib/polytrix/version.rb +1 -1
  57. data/lib/polytrix.rb +55 -33
  58. data/polytrix.gemspec +4 -2
  59. data/polytrix.rb +0 -5
  60. data/{polytrix_tests.yml → polytrix.yml} +5 -0
  61. data/samples/default_bootstrap.rb +0 -7
  62. data/samples/polytrix.rb +0 -9
  63. data/samples/{polytrix_tests.yml → polytrix.yml} +11 -0
  64. data/samples/polytrix_cli.sh +1 -1
  65. data/spec/fabricators/implementor_fabricator.rb +20 -0
  66. data/spec/fabricators/manifest_fabricator.rb +4 -1
  67. data/spec/fixtures/{polytrix_tests.yml → polytrix.yml} +10 -0
  68. data/spec/polytrix/challenge_runner_spec.rb +3 -2
  69. data/spec/polytrix/challenge_spec.rb +5 -4
  70. data/spec/polytrix/cli_spec.rb +23 -26
  71. data/spec/polytrix/configuration_spec.rb +4 -43
  72. data/spec/polytrix/documentation/helpers/code_helper_spec.rb +1 -1
  73. data/spec/polytrix/documentation_generator_spec.rb +2 -0
  74. data/spec/polytrix/implementor_spec.rb +44 -2
  75. data/spec/polytrix/manifest_spec.rb +7 -4
  76. data/spec/polytrix_spec.rb +9 -11
  77. data/spec/thor_spy.rb +2 -0
  78. metadata +66 -16
  79. data/features/fixtures/spec/polytrix_merge.rb +0 -5
  80. data/features/reporting.feature +0 -140
  81. data/lib/polytrix/executor.rb +0 -89
  82. data/samples/sdks/custom/polytrix.yml +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c91cf7e97c088e23aa0134c2e20acfab0640195
4
- data.tar.gz: 9bd8c63ae3cfbbc3bc75fc54c3b094ad848dd8c7
3
+ metadata.gz: 57453fe422a3e27d1aaa87f79689d05c8aa9bcc0
4
+ data.tar.gz: b3fd502c953d29fba9948eb12053b1341d1ce15b
5
5
  SHA512:
6
- metadata.gz: 5361e579064d58b4168e5929f995d1a42506c2faa49b246ddccd83eec3f2adef3d28b2761ab0bfd9b173e6ef690702b7eba56caef2e1a75746045c48c29e97b3
7
- data.tar.gz: 61bcc9b099b67a95695cc59ac0d23baf3791cb8eec7c1bed382964c25e03ebc18fac01e6bce5bed6be1666e45a58ada4ef611323121dcf1bdc5c43c3c4f6823c
6
+ metadata.gz: 3ad963f3478969e5d44cfce5f10e652d94acaa488a9fe5969c377f0ca1133325c022201e211338be5d1b9917664ccdef702b307564cd9258e621d62ca26050c7
7
+ data.tar.gz: 80e47b9677116fbc2652dc38a54ab0979bc11b10a00cffee865a1026a3bb1609763464a1a67d455714ec3832df1cac33f9676dbae827f309a54d1e4164900d4a
data/.gitignore CHANGED
@@ -11,3 +11,4 @@ node_modules/
11
11
  pkg/
12
12
  coverage/
13
13
  .yardoc/
14
+ .polytrix/
data/.rubocop.yml CHANGED
@@ -1,10 +1,15 @@
1
1
  inherit_from: .rubocop-todo.yml
2
2
 
3
+ Encoding:
4
+ Enabled: false
5
+ # EnforcedStyle: when_needed
6
+
3
7
  AllCops:
4
8
  Include:
5
9
  - Guardfile
6
10
  - Rakefile
7
11
  - pacto.gemspec
8
12
  Exclude:
9
- - bin/**
10
- - tmp/**
13
+ - bin/**/*
14
+ - tmp/**/*
15
+ - tmp/**/*.rb
data/.travis.yml CHANGED
@@ -1,11 +1,12 @@
1
1
  before_install:
2
- - sudo add-apt-repository ppa:cwchien/gradle
2
+ - sudo add-apt-repository -y ppa:cwchien/gradle
3
3
  - sudo apt-get update -qq
4
4
  - sudo apt-get install -qq gradle
5
5
  rvm:
6
6
  - 1.9.3
7
7
  - 2.0.0
8
8
  - 2.1.0
9
+ - jruby
9
10
  allow_failures:
10
11
  rvm:
11
12
  - 1.9.3 # YAML formatting differs
data/Gemfile CHANGED
@@ -5,3 +5,4 @@ gemspec
5
5
  gem "pry"
6
6
  gem "rake-notes"
7
7
  gem "simplecov"
8
+ gem 'hashie', :git => 'https://github.com/intridea/hashie'
data/README.md CHANGED
@@ -1,139 +1,231 @@
1
1
  # Polytrix - the Polyglot Testing Matrix
2
2
 
3
- Polytrix is a polyglot test runner and documentation generator. It aims to let you run sample code written in any language. It's especially useful if you want to run similar code samples in multiple languages. Simply put, if a project like [Slate](https://github.com/tripit/slate) looks like an interesting documentation option, then you might be interested in Polytrix for testing.
3
+ Polytrix is a polyglot test runner and documentation generator. It aims to let you run sample code written in any language. It's especially useful if you want to run similar code samples in multiple languages, a project that has been ported to several languages, or API clients for the same service that are provided in several languages.
4
4
 
5
- # Features
5
+ Polytrix was influenced by a number of polyglot projects, including [Travis-CI](travis-ci.org), [Docco](https://github.com/jashkenas/docco), [Slate](https://github.com/tripit/slate), and polyglot test-suites like the [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite) and the [JSON-LD Test Suite](http://json-ld.org/test-suite/).
6
6
 
7
- Polytrix samples defined in a "test manifest" written in YAML. The test manifest is meant to be portable so you can use you can create a "lightweight sample runner" in your preferred build/test tool of choice for your language, and then integrate the samples with Polytrix later to get the extra features. Polytrix can:
8
- - Run sample code in any language and several platforms
9
- - Perform compatibility testing checking multiple implementations (in different langauges) against the same set of assertions
10
- - Generate documentation from sample code and test results
11
- - Generate compatibility or feature matrix reports
7
+ The user-experience was heavily influenced by [test-kitchen](http://kitchen.ci/). Polytrix aims to do for multi-language development of command-line applications what test-kitchen has done for multi-platform development of infrastructure.
12
8
 
13
- Polytrix provides a few built-in assertions, but also has a plugin system that you can use to do more advanced validation, like using [Pacto](https://github.com/thoughtworks/pacto) to intercept and validate the usage of RESTful services.
9
+ ## Installing Polytrix
14
10
 
15
- # Usage preview
11
+ Polytrix is distributed as a Ruby Gem. It should be installed using Bundler by adding this line to your Gemfile:
16
12
 
17
- Polytrix is currently run via rspec. You can create a script that looks like this and run it with rspec:
18
-
19
- ```ruby
20
- require 'polytrix/rspec'
21
-
22
- Polytrix.implementors = Dir['sdks/*'].map{ |sdk|
23
- name = File.basename(sdk)
24
- Polytrix::Implementor.new :name => name
25
- }
26
-
27
- Polytrix.load_manifest 'polytrix_tests.yml'
28
- Polytrix.bootstrap
29
- Polytrix.run_tests
13
+ ```shell
14
+ gem 'polytrix', '~> 0.1'
30
15
  ```
31
16
 
32
- Polytrix will use the information in the Manifest and Implementors (see the sections below) to build an rspec test suite. It will setup tags for each Implementor, and names corresponding with the tests in the manifest.
17
+ And then running `bundle install`.
33
18
 
34
- So in our Polytrix examples project you can use commands like:
19
+ It can also be installed without Bundler by running `gem install polytrix`.
35
20
 
36
- ```sh
37
- $ # Only run tests for the Java implementor
38
- $ bundle exec rspec -t java
39
- $ # Run the "hello world" tests in each language
40
- $ bundle exec rspec -e "hello world"
41
- ```
21
+ ## Getting Help
42
22
 
43
- ## Usage Breakdown
23
+ Polytrix is primarily intented to be run as a standalone utility, though it does have an API for integrating with RSpec or other Ruby-based test frameworks.
44
24
 
45
- ### Defining Implementors (SDKs)
25
+ Note: You may need to prefix commands with `bundle exec` if you installed Polytrix using Bundler.
46
26
 
47
- Polytrix can run the tests against multiple implementors. This usually means an SDK, but we used the generic term implementor because Polytrix works equally well for testing code katas, coursework, or other items. Perhaps even things like multi-platform plugins for [Calatrava](https://github.com/calatrava/calatrava/wiki/Plugins) or [PhoneGap](http://docs.phonegap.com/en/3.4.0/guide_hybrid_plugins_index.md.html#Plugin%20Development%20Guide).
27
+ If you need a quick reminder of what the `polytrix` command gives you, then use the **help** subcommand:
48
28
 
49
- This snippet defines the implementors:
50
- ```ruby
51
- Polytrix.implementors = Dir['sdks/*'].map{ |sdk|
52
- name = File.basename(sdk)
53
- Polytrix::Implementor.new :name => name
54
- }
29
+ ```
30
+ $ bundle exec polytrix help
31
+ Commands:s
32
+ polytrix bootstrap [(all|<REGEX>)] [opts] # Bootstraps the code samples for one or more tests
33
+ polytrix code2doc [(all|<REGEX>)] [opts] # Converts annotated code samples to Markdown or reStructuredText
34
+ polytrix clean [(all|<REGEX>)] [opts] # Removes test results for one or more tests
35
+ polytrix clone [(all|<REGEX>)] [opts] # Clones the code samples from git for one or more tests
36
+ polytrix exec [(all|<REGEX>)] [opts] # Executes code samples for one or more tests
37
+ polytrix help [COMMAND] # Describe available commands or one specific command
38
+ polytrix list [(all|<REGEX>)] [opts] # List all tests
39
+ polytrix test [all|<REGEX>)] [opts] # Test one or more tests
40
+ polytrix verify [(all|<REGEX>)] [opts] # Verify the execution results of one or more tests
41
+ polytrix version # Print Polytrix's version information
55
42
  ```
56
43
 
57
- See the full Implementor documentation for details on other attributes you can set, like `:language`. Polytrix will try to infer any information you don't pass.
58
-
59
- #### Bootstrapping, compiling, wrapper scripts
44
+ ## The polytrix.yml file
60
45
 
61
- Polytrix currently uses the [script/bootstrap](http://wynnnetherland.com/linked/2013012801/bootstrapping-consistency) pattern to allow each implementor to hook into dependency management, build tools, or other systems. Polytrix will look for three scripts (on Windows it will look for a *.ps1 version written in PowerShell):
46
+ The Polytrix test suites and the implementors that should be tested are defined in a polytrix.yml file.
47
+ A basic file looks like this:
62
48
 
63
- | File | Purpose |
64
- | ---------------- | -------------------------------------------------------------- |
65
- | script/bootstrap | Prepare the SDK, usually by running depenency management tool. |
66
- | script/wrapper | Wrapper script instead of executing code samples as scripts |
49
+ ```yaml
50
+ polytrix:
51
+ implementors:
52
+ ruby_samples:
53
+ language: ruby
54
+ bootstrap_cmd: bundle install
55
+ exec_cmd: bundle exec ruby
56
+ git:
57
+ repo: https://github.com/polytrix/ruby_samples
58
+ python_samples:
59
+ language: python
60
+ bootstrap_script: scripts/pip_install
61
+ exec_script: scripts/pip_install
62
+ git:
63
+ repo: https://github.com/polytrix/python_samples
64
+ java_samples:
65
+ language: java
66
+ # The default is to look for scripts/bootstrap and scripts/exec
67
+ # or try to use the default bootstrap/exec behavior for the language
68
+ git:
69
+ repo: 'https://github.com/polytrix/java_samples'
70
+
71
+ suites:
72
+ katas:
73
+ code_samples:
74
+ hello_world:
75
+ - validate:
76
+ stdout: Hello, World!
77
+ quine:
78
+ - validate:
79
+ quine_validator: true
80
+ utilities:
81
+ code_samples:
82
+ word_count:
83
+ - name: short text
84
+ input: |
85
+ I am a word count utility
86
+ validate:
87
+ stdout: 6 words
88
+ - name: small file
89
+ input_file: fixtures/small_file.txt
90
+ validate:
91
+ stdout: 10 words
92
+ - name: large file
93
+ input_file: fixtures/large_file.txt
94
+ validate:
95
+ stdout: 1000 words
96
+ ```
67
97
 
68
- The bootstrap script is called by `Polytrix.bootstrap`. The wrapper script, if it exists, wraps the executino of the code sample. If there is no wrapper script, Polytrix will try to execute the sample code as a script. That works for many non-compiled scripting languages, like Ruby or Python, but won't work for something like Java.
98
+ ### Defining Implementors
99
+
100
+ Polytrix tests scenarios across one or more implementors. The implementors may each be in a different
101
+ language, but you can also have multiple implementors for the same langauge. The structure used to define implementors within polytrix.yml is described below.
102
+
103
+ #### Implementor Object
104
+
105
+ Field Name | Type | Description
106
+ ---|:---:|---
107
+ <a name="implementor_name"/>name | `string` | The name of the implementor. (*If omitted, this attribute’s value defaults to the key name associated with this object.*)
108
+ <a name="implementor_directory"/>directory | `string` | The location of the implementor project containing code samples.
109
+ <a name="implementor_language"/>language | `string` | The primary programming language of the code samples in this implementor.
110
+ <a name="implementor_git"/>git | [Git Object](#git_object) | Defines how to clone the project via Git.
111
+ <a name="implementor_scripts"/>scripts | [Scripts Object](#scripts_object) | Defines scripts to bootstrap, compile, and execute the samples.
112
+
113
+ #### Git Object
114
+ <a name="git_object"/>Field Name | Type | Description
115
+ ---|:---:|---
116
+ <a name="git_repo"/>repo | `string` | **Required.** The git repo to clone.
117
+ <a name="git_branch"/>branch | `string` | The git branch to clone.
118
+ <a name="git_to"/>to | `string` | The local directory to clone into.
119
+
120
+ #### Scripts Object
121
+ <a name="scripts_object"/>Field Name | Type | Description
122
+ ---|:---:|---
123
+ <a name="directory"/>directory | `directory` | The directory that contains the script files. **Default**: `scripts/`.
124
+ <a name="bootstrap_script"/>bootstrap_script | `file` | The file to execute to bootstrap the samples. **Default**: `bootstrap`
125
+ <a name="compile_script"/>compile_script | `file` | The file to execute to compile the samples. **Default**: `compile`
126
+ <a name="exec_script"/>exec_script | `file` | The file to use as an execute wrapper script for running samples. **Default**: `exec`
127
+ <a name="bootstrap_cmd"/>bootstrap_cmd | `string` | An inline script to execute instead of executing *bootstrap_file*.
128
+ <a name="compile_cmd"/>compile_cmd | `string` | An inline script to execute instead of executing *bootstrap_file*.
129
+ <a name="exec_cmd"/>exec_cmd | `string` | An inline script to use as an execution wrapper, instead of searching for a `exec` script.
130
+
131
+ #### Example Implementor Definition
69
132
 
70
- If there is a wrapper script, Polytrix will call it with teh sample source file as the first argument, e.g.:
71
- ```sh
72
- $ cd my_java_sdk
73
- $ ./script/wrapper src/samples/HelloWorld.java
133
+ ```yaml
134
+ implementors:
135
+ ruby_samples:
136
+ directory: samples/ruby
137
+ language: ruby
138
+ git:
139
+ repo: https://github.com/polytrix/ruby_samples
140
+ branch: master
141
+ to: samples/ruby
142
+ scripts:
143
+ bootstrap_cmd: bundle install
144
+ exec_cmd: bundle exec ruby "$@"
74
145
  ```
75
146
 
76
- ### Defining tests - the test manifest
147
+ ### Attaching Code Samples
77
148
 
78
- Tests are defined in a YAML "test manifest" which defines what sample code should be executed, and what input it should receive. Standardizing the input is important for compliance testing, becaues it is difficult to maintain tests where one example expects "FOO=bar" and another expects "--foo bar".
149
+ Polytrix tests are divided into suites, code samples, and scenarios. Each tuple (suite, code sample, scenario) is a test.
79
150
 
80
- A simple test manifest looks like this:
81
- ```yaml
82
- ---
83
- global_env: # global_env defines input available for all scenarios
84
- LOCALE: <%= ENV['LANG'] %> # templating is allowed
85
- FAVORITE_NUMBER: 5
86
- suites: # suites defines the test suites that can be executed
87
- Katas: # "Katas" is the name of the first suite
88
- env: # These "env" values are only available within the "Katas" suite
89
- NAME: 'Max'
90
- samples: # samples defines the individual tests in a suite
91
- - hello world
92
- - quine
93
- Tutorials: # "Tutorials" is the name of the second suite
94
- env:
95
- samples:
96
- - deploying
97
- - documenting
98
- ```
151
+ The structure used to define tests is:
152
+
153
+ #### Suite Object
99
154
 
100
- ### Test setup
155
+ Field Name | Type | Description
156
+ ---|:---:|---
157
+ <a name="suite_name"/>name | `string` | The name of the suite. (*If omitted, this attribute’s value defaults to hash key associated with this object.*)
158
+ <a name="suite_input"/>input | `string` | The content to send to the code sample as standard input.
159
+ <a name="suite_input_file"/>input_file | `file` | Reads the specified file and sets *input*.
160
+ <a name="code_samples"/>code_samples | Hash of [Code Samples](#code_samples) | Defines the code samples to test
101
161
 
102
- `Polytrix.run_tests` runs the tests. Actually, right now it really just defines them in rspec, you still need to run the whole script via the RSpec command for the tests to run.
162
+ #### Code Sample Object
103
163
 
104
- ### Finding samples
164
+ The code sample object determines which scenario to runwhich determines which code sample will be run. It can also
165
+ override the default values set in the Suite Object.
105
166
 
106
- Polytrix finds samples based on a loose naming convention. This makes it easier to use file names that are idiomatic for each implementor, while still allowing Polytrix to find the right file.
167
+ If the Scenario Object is a list, it will be automatically split into distinct but related scenarios. This is useful
168
+ for testing the same code sample with a variety of different input values.
107
169
 
108
- Polytrix basically does a case-insensitive search for a file whose name matches the scenario name, ignoring subfolders, spaces, prefixes, puctuation and file extension. So these files all match a scenario named "hello world":
109
- - hello_world.rb
110
- - src/com/world/HelloWorld.java
111
- - samples/01_hello_world.go
170
+ Field Name | Type | Description
171
+ ---|:---:|---
172
+ <a name="code_sample_name"/>name | `string` | The name of the suite. (*If omitted, this attribute’s value defaults to hash key associated with this object.*)
173
+ <a name="scenarios"/>scenarios | List of [Scenario Objects](#scenario_object) | Defines the scenarios to test for the code sample. **Default**: An scenario named default with no input.
112
174
 
113
- ### Reports and documentation
114
175
 
115
- You can use any RSpec formatter with Polytrix, since Polytrix is based on RSpec.
176
+ #### Scenario Object
116
177
 
117
- There are also some Polytrix specific documentation and report generators. You can generate:
118
- - Scenario-level reports: Documentation or reports for a single scenario
119
- - Global reports: Documentation or reports summarizing all tested scenarios
178
+ Field Name | Type | Description
179
+ ---|:---:|---
180
+ <a name="scenario_name"/>name | `string` | **Required.** The scenario name.
181
+ <a name="scenario_input"/>input | `string` | The content to send to the code sample as standard input.
182
+ <a name="scenario_input_file"/>input_file | `file` | Reads the specified file and sets *input*.
183
+ <a name="scenarios"/>language | Hash of [Scenario Objects](#scenario_object) | Defines the scenarios within the suite
120
184
 
121
- The documentatio/reports are generated via a template processing system. Polytrix searches the template directory ('doc-src/' by default) for scenario-level samples using the same logic as in the "Finding samples" section above. It looks for a template matching "index" (e.g. index.md, index.rst, index.html) for the global report.
185
+ #### Example Suite Definition
122
186
 
123
- The templates are processed as ERB. In addition to being able to access the top-level Polytrix API, the following variables are bound:
124
- | Variable | Description |
125
- | ---------- | ---------------------------------------- |
126
- | scenario | The name of the scenario being processed |
127
- | challenges | One or more Challenge objects containing the scenario configuration and results |
187
+ ```yaml
188
+ suites:
189
+ katas:
190
+ scenarios:
191
+ hello_world:
192
+ validate:
193
+ stdout: Hello, World!
194
+ quine:
195
+ validate:
196
+ quine_validator: true
197
+ utilities:
198
+ scenarios:
199
+ word_count:
200
+ - name: short text
201
+ input: |
202
+ I am a word count utility
203
+ validate:
204
+ stdout: 6 words
205
+ - name: small file
206
+ input_file: fixtures/small_file.txt
207
+ validate:
208
+ stdout: 10 words
209
+ - name: large file
210
+ input_file: fixtures/large_file.txt
211
+ validate:
212
+ stdout: 1000 words
213
+ ```
128
214
 
129
- ### Common compliance tests
215
+ ## Plugins
130
216
 
131
- Refactoring... documentation coming soon.
217
+ TBD
132
218
 
133
- ### Plugins
219
+ ## Custom Validators
134
220
 
135
- Refactoring... documentation coming soon.
221
+ TBD
136
222
 
137
- # Influences
223
+ ## Usage
138
224
 
139
- Several projects have influenced ideas in Polytrix. If you find Polytrix interesting or want to contribute, you may want to look at those projects. See influence.md.
225
+ ### Cloning implementors
226
+ ### Bootstrapping implementors
227
+ ### Executing scenarios
228
+ ### Verifying scenario results
229
+ ### Full test
230
+
231
+ ```
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ RSpec::Core::RakeTask.new('spec') do |t|
13
13
  end
14
14
 
15
15
  Cucumber::Rake::Task.new(:features) do |t|
16
- t.cucumber_opts = "features --require features/support --require features/step_definitions"
16
+ t.cucumber_opts = "features --require features/support --require features/step_definitions -t ~@wip"
17
17
  end
18
18
 
19
19
  desc 'Remove reports and other generated artifacts'
@@ -25,11 +25,13 @@ end
25
25
  desc 'Self-test and self-document'
26
26
  task :self do
27
27
  sh 'bundle exec polytrix bootstrap'
28
- sh 'bundle exec polytrix test'
29
- sh 'bundle exec polytrix code2doc samples/sdks/java/challenges/*.java --target-dir=docs/samples/code2doc/java'
30
- sh 'bundle exec polytrix code2doc samples/sdks/python/challenges/*.py --target-dir=docs/samples/code2doc/python'
31
- sh 'bundle exec polytrix code2doc samples/sdks/ruby/challenges/*.rb --target-dir=docs/samples/code2doc/ruby'
32
- # sh 'bundle exec polytrix code2doc samples/*.rb'
28
+ Dir.chdir 'samples' do
29
+ # sh 'bundle exec polytrix test'
30
+ sh 'bundle exec polytrix code2doc java --target-dir=docs/samples/code2doc/java'
31
+ sh 'bundle exec polytrix code2doc python --target-dir=docs/samples/code2doc/python'
32
+ sh 'bundle exec polytrix code2doc ruby --target-dir=docs/samples/code2doc/ruby'
33
+ # sh 'bundle exec polytrix code2doc samples/*.rb'
34
+ end
33
35
  end
34
36
 
35
37
  Rubocop::RakeTask.new(:rubocop) do |task|
data/bin/polytrix CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'polytrix/error'
2
3
  require 'polytrix/cli'
3
4
 
4
5
  $LOAD_PATH << 'spec'
5
- Polytrix::CLI::Main.start
6
+ Polytrix.with_friendly_errors { Polytrix::CLI.start }
@@ -1,13 +1,17 @@
1
1
  This is an example of the standard [Hello World](http://en.wikipedia.org/wiki/Hello_world_program)
2
2
  program written in [Java][java].
3
+
3
4
  ```java
4
5
  public class HelloWorld {
5
6
  ```
7
+
6
8
  A Java CLI application is defined by creating a main method with this signature:
9
+
7
10
  ```java
8
11
  public static void main(String[] args) {
9
12
  System.out.println("Hello, world!");
10
13
  }
11
14
  }
12
15
  ```
16
+
13
17
  [java]: http://en.wikipedia.org/wiki/Java_(programming_language)
@@ -1,3 +1,4 @@
1
+
1
2
  ```java
2
3
  public class Quine
3
4
  {
@@ -31,3 +32,4 @@ public class Quine
31
32
  }
32
33
  }
33
34
  ```
35
+
@@ -1,3 +1,5 @@
1
+
1
2
  ```py
2
3
  print 'Hello, world!'
3
4
  ```
5
+
@@ -1,4 +1,6 @@
1
+
1
2
  ```py
2
3
  s = 's = %r\nprint(s%%s)'
3
4
  print(s%s)
4
5
  ```
6
+
@@ -1,7 +1,11 @@
1
+
1
2
  ```rb
2
3
  name = 'world'
3
4
  ```
5
+
4
6
  This will print Hello, world!
7
+
5
8
  ```rb
6
9
  puts "Hello, #{name}!"
7
10
  ```
11
+
@@ -0,0 +1,36 @@
1
+ Feature: Boostrapping
2
+
3
+ Polytrix uses the [script/bootstrap](http://wynnnetherland.com/linked/2013012801/bootstrapping-consistency) pattern to prepare SDKs for testing. You can hook into any package manager, compiler, build tool, or any other toolchain to prepare to build and run samples.
4
+
5
+ Scenario: Bootstrapping all SDKs
6
+ Given the ruby SDK
7
+ And the java SDK
8
+ And the python SDK
9
+ And the hello_world polytrix config
10
+ And the standard rspec setup
11
+ When I run `bundle exec polytrix bootstrap`
12
+ Then the output should contain "-----> Bootstrapping java"
13
+ Then the output should contain "-----> Bootstrapping python"
14
+ Then the output should contain "-----> Bootstrapping ruby"
15
+
16
+ Scenario: Bootstrapping selected SDKs
17
+ Given the ruby SDK
18
+ And the java SDK
19
+ And the python SDK
20
+ And the hello_world polytrix config
21
+ And the standard rspec setup
22
+ When I run `bundle exec polytrix bootstrap "(java|ruby)"`
23
+ Then the output should contain "-----> Bootstrapping java"
24
+ Then the output should not contain "-----> Bootstrapping python"
25
+ Then the output should contain "-----> Bootstrapping ruby"
26
+
27
+ Scenario: Bootstrapping by scenario
28
+ Given the ruby SDK
29
+ And the java SDK
30
+ And the python SDK
31
+ And the hello_world polytrix config
32
+ And the standard rspec setup
33
+ When I run `bundle exec polytrix bootstrap hello`
34
+ Then the output should contain "-----> Bootstrapping java"
35
+ Then the output should contain "-----> Bootstrapping python"
36
+ Then the output should contain "-----> Bootstrapping ruby"
@@ -0,0 +1,34 @@
1
+ @wip
2
+ Feature: Cloning
3
+
4
+ Polytrix can clone projects from git.
5
+
6
+ Scenario: Cloning all SDKs
7
+ Given the hello_world polytrix config
8
+ And the standard rspec setup
9
+ When I run `bundle exec polytrix clone`
10
+ Then the output should contain "-----> Cloning java"
11
+ Then the output should contain "-----> Cloning python"
12
+ Then the output should contain "-----> Cloning ruby"
13
+
14
+ Scenario: Cloning selected SDKs
15
+ Given the ruby SDK
16
+ And the java SDK
17
+ And the python SDK
18
+ And the hello_world polytrix config
19
+ And the standard rspec setup
20
+ When I run `bundle exec polytrix clone "(java|ruby)"`
21
+ Then the output should contain "-----> Cloning java"
22
+ Then the output should not contain "-----> Cloning python"
23
+ Then the output should contain "-----> Cloning ruby"
24
+
25
+ Scenario: Cloning by scenario
26
+ Given the ruby SDK
27
+ And the java SDK
28
+ And the python SDK
29
+ And the hello_world polytrix config
30
+ And the standard rspec setup
31
+ When I run `bundle exec polytrix clone hello`
32
+ Then the output should contain "-----> Cloning java"
33
+ Then the output should contain "-----> Cloning python"
34
+ Then the output should contain "-----> Cloning ruby"
@@ -4,15 +4,7 @@ Feature: Running SDKs
4
4
 
5
5
  Polytrix also sets up tags for the SDKs so you can use the normal rspec `-t` option to select which SDK to run.
6
6
 
7
- Scenario: Bootstrap an SDK
8
- Given the java SDK
9
- And the empty polytrix config
10
- And the standard rspec setup
11
- When I run `bundle exec rspec`
12
- Then the output should contain ":compileJava"
13
- And the output should contain "BUILD SUCCESSFUL"
14
-
15
- Scenario: Running all SDKs
7
+ Scenario: Running all SDKs
16
8
  Given the ruby SDK
17
9
  And the java SDK
18
10
  And the python SDK
@@ -41,13 +33,6 @@ Scenario: Running all SDKs
41
33
  """
42
34
  require 'polytrix/rspec'
43
35
 
44
- Polytrix.configure do |polytrix|
45
- Dir['sdks/*'].each do |sdk|
46
- polytrix.implementor sdk
47
- end
48
- polytrix.test_manifest = 'polytrix_tests.yml'
49
- end
50
-
51
36
  # This is more of an integration test, but makes sure the rspec API is working.
52
37
  # Expect results to all be pending, because there's no implementors in this proj.
53
38
 
@@ -62,6 +47,7 @@ Scenario: Running all SDKs
62
47
  expect(challenge[:result].execution_result.stdout).to eq File.read(challenge[:result].source)
63
48
  end
64
49
  Polytrix.load_tests
50
+
65
51
  """
66
52
  When I run `bundle exec rspec spec/custom_spec.rb`
67
53
  And the output should match /expected: 1\s+got: 0/
@@ -1,4 +1,15 @@
1
1
  ---
2
+ implementors:
3
+ ruby:
4
+ language: 'ruby'
5
+ basedir: 'sdks/ruby'
6
+ java:
7
+ language: 'java'
8
+ basedir: 'sdks/java'
9
+ python:
10
+ language: 'python'
11
+ basedir: 'sdks/python'
12
+
2
13
  global_env:
3
14
  LOCALE: <%= ENV['LANG'] %>
4
15
  FAVORITE_NUMBER: 5
@@ -9,4 +20,4 @@
9
20
  samples:
10
21
  Tutorials:
11
22
  env:
12
- samples:
23
+ samples:
@@ -1,4 +1,14 @@
1
1
  ---
2
+ implementors:
3
+ ruby:
4
+ language: 'ruby'
5
+ basedir: 'sdks/ruby'
6
+ java:
7
+ language: 'java'
8
+ basedir: 'sdks/java'
9
+ python:
10
+ language: 'python'
11
+ basedir: 'sdks/python'
2
12
  global_env:
3
13
  LOCALE: <%= ENV['LANG'] %>
4
14
  FAVORITE_NUMBER: 5
@@ -7,4 +17,4 @@
7
17
  env:
8
18
  NAME: 'Max'
9
19
  samples:
10
- - hello world
20
+ - hello world