polytrix 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop-todo.yml +14 -5
  3. data/Gemfile +2 -1
  4. data/README.md +139 -177
  5. data/Rakefile +5 -12
  6. data/bin/polytrix +0 -1
  7. data/features/bootstrapping.feature +0 -3
  8. data/features/cloning.feature +0 -3
  9. data/features/show.feature +38 -0
  10. data/features/states.feature +12 -13
  11. data/features/step_definitions/sdk_steps.rb +0 -4
  12. data/lib/polytrix/challenge.rb +135 -53
  13. data/lib/polytrix/challenge_result.rb +0 -2
  14. data/lib/polytrix/challenge_runner.rb +28 -18
  15. data/lib/polytrix/cli.rb +53 -69
  16. data/lib/polytrix/color.rb +2 -2
  17. data/lib/polytrix/command/action.rb +4 -3
  18. data/lib/polytrix/command/list.rb +39 -28
  19. data/lib/polytrix/command/report.rb +9 -86
  20. data/lib/polytrix/command/reports/code2doc.rb +72 -0
  21. data/lib/polytrix/command/reports/dashboard.rb +125 -0
  22. data/lib/polytrix/command/show.rb +148 -0
  23. data/lib/polytrix/command.rb +37 -104
  24. data/lib/polytrix/configuration.rb +14 -18
  25. data/lib/polytrix/{core/hashie.rb → dash.rb} +4 -3
  26. data/lib/polytrix/documentation/code_segmenter.rb +8 -8
  27. data/lib/polytrix/documentation/comment_styles.rb +1 -1
  28. data/lib/polytrix/documentation/helpers/code_helper.rb +9 -0
  29. data/lib/polytrix/documentation_generator.rb +11 -14
  30. data/lib/polytrix/error.rb +104 -97
  31. data/lib/polytrix/executor.rb +33 -0
  32. data/lib/polytrix/{runners → executors}/buff_shellout_executor.rb +1 -1
  33. data/lib/polytrix/executors/linux_challenge_executor.rb +29 -0
  34. data/lib/polytrix/executors/mixlib_shellout_executor.rb +55 -0
  35. data/lib/polytrix/{runners/windows_challenge_runner.rb → executors/windows_challenge_executor.rb} +4 -11
  36. data/lib/polytrix/{core/implementor.rb → implementor.rb} +10 -6
  37. data/lib/polytrix/manifest.rb +2 -31
  38. data/lib/polytrix/{reports → reporters}/hash_reporter.rb +6 -2
  39. data/lib/polytrix/{reports → reporters}/json_reporter.rb +2 -2
  40. data/lib/polytrix/{reports → reporters}/markdown_reporter.rb +7 -2
  41. data/lib/polytrix/{reports → reporters}/yaml_reporter.rb +2 -2
  42. data/lib/polytrix/reporters.rb +27 -0
  43. data/lib/polytrix/result.rb +6 -5
  44. data/lib/polytrix/spies/file_system_spy.rb +15 -0
  45. data/lib/polytrix/spies.rb +61 -0
  46. data/lib/polytrix/state_file.rb +1 -20
  47. data/lib/polytrix/util.rb +157 -62
  48. data/lib/polytrix/validation.rb +41 -2
  49. data/lib/polytrix/validator.rb +9 -4
  50. data/lib/polytrix/version.rb +1 -1
  51. data/lib/polytrix.rb +110 -105
  52. data/polytrix.gemspec +7 -2
  53. data/polytrix.yml +16 -13
  54. data/resources/assets/pygments/autumn.css +58 -0
  55. data/resources/assets/pygments/borland.css +46 -0
  56. data/resources/assets/pygments/bw.css +34 -0
  57. data/resources/assets/pygments/colorful.css +61 -0
  58. data/resources/assets/pygments/default.css +62 -0
  59. data/resources/assets/pygments/emacs.css +61 -0
  60. data/resources/assets/pygments/friendly.css +61 -0
  61. data/resources/assets/pygments/fruity.css +69 -0
  62. data/resources/assets/pygments/github.css +61 -0
  63. data/resources/assets/pygments/manni.css +61 -0
  64. data/resources/assets/pygments/monokai.css +64 -0
  65. data/resources/assets/pygments/murphy.css +61 -0
  66. data/resources/assets/pygments/native.css +69 -0
  67. data/resources/assets/pygments/pastie.css +60 -0
  68. data/resources/assets/pygments/perldoc.css +58 -0
  69. data/resources/assets/pygments/tango.css +69 -0
  70. data/resources/assets/pygments/trac.css +59 -0
  71. data/resources/assets/pygments/vim.css +69 -0
  72. data/resources/assets/pygments/vs.css +33 -0
  73. data/resources/assets/pygments/zenburn.css +1 -0
  74. data/resources/assets/style.css +41 -0
  75. data/resources/templates/dashboard/files/dashboard.html.tt +82 -0
  76. data/resources/templates/dashboard/templates/_test_report.html.tt +87 -0
  77. data/samples/bootstrap.sh +2 -0
  78. data/samples/clone.sh +2 -0
  79. data/samples/code2doc.sh +4 -0
  80. data/samples/docs/samples/code2doc/java/katas-hello_world-java.md +17 -0
  81. data/samples/docs/samples/code2doc/java/katas-quine-java.md +35 -0
  82. data/samples/docs/samples/code2doc/python/katas-hello_world-python.md +5 -0
  83. data/samples/docs/samples/code2doc/python/katas-quine-python.md +6 -0
  84. data/samples/docs/samples/code2doc/ruby/katas-hello_world-ruby.md +11 -0
  85. data/samples/exec.sh +2 -0
  86. data/samples/polytrix.rb +2 -2
  87. data/samples/polytrix.yml +5 -2
  88. data/samples/show.sh +4 -0
  89. data/samples/test.sh +2 -0
  90. data/samples/tests/polytrix/validators.rb +2 -2
  91. data/samples/verify.sh +3 -0
  92. data/scripts/wrapper +4 -7
  93. data/spec/fabricators/challenge_fabricator.rb +2 -9
  94. data/spec/fabricators/implementor_fabricator.rb +0 -8
  95. data/spec/fabricators/manifest_fabricator.rb +2 -9
  96. data/spec/fabricators/validator_fabricator.rb +2 -4
  97. data/spec/polytrix/challenge_runner_spec.rb +20 -0
  98. data/spec/polytrix/documentation/helpers/code_helper_spec.rb +7 -7
  99. data/spec/polytrix/file_finder_spec.rb +5 -5
  100. data/spec/polytrix/manifest_spec.rb +0 -21
  101. data/spec/polytrix/result_spec.rb +14 -14
  102. data/spec/polytrix/validator_registry_spec.rb +4 -4
  103. data/spec/polytrix/validator_spec.rb +9 -9
  104. data/spec/polytrix_spec.rb +1 -25
  105. data/spec/spec_helper.rb +8 -1
  106. metadata +130 -38
  107. data/features/execution.feature +0 -53
  108. data/features/fixtures/spec/polytrix_spec.rb +0 -7
  109. data/lib/polytrix/cli/report.rb +0 -84
  110. data/lib/polytrix/command/rundoc.rb +0 -27
  111. data/lib/polytrix/core/file_system_helper.rb +0 -75
  112. data/lib/polytrix/core/manifest_section.rb +0 -4
  113. data/lib/polytrix/core/string_helpers.rb +0 -15
  114. data/lib/polytrix/documentation/view_helper.rb +0 -21
  115. data/lib/polytrix/rspec/documentation_formatter.rb +0 -66
  116. data/lib/polytrix/rspec/yaml_report.rb +0 -51
  117. data/lib/polytrix/rspec.rb +0 -56
  118. data/lib/polytrix/runners/executor.rb +0 -34
  119. data/lib/polytrix/runners/linux_challenge_runner.rb +0 -23
  120. data/lib/polytrix/runners/middleware/change_directory.rb +0 -20
  121. data/lib/polytrix/runners/middleware/feature_executor.rb +0 -24
  122. data/lib/polytrix/runners/middleware/setup_env_vars.rb +0 -42
  123. data/lib/polytrix/runners/mixlib_shellout_executor.rb +0 -83
  124. data/lib/polytrix/validations.rb +0 -23
  125. data/samples/scripts/wrapper +0 -7
  126. data/spec/polytrix/middleware/feature_executor_spec.rb +0 -48
  127. data/spec/polytrix/validations_spec.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93880fb633954c24e251130dc5e0c081400ec997
4
- data.tar.gz: d35447d2afba85aacdcbee6649585d954bea2ea7
3
+ metadata.gz: 1e1a7bfe5588d1217cd43593060f0ca6d2ffc5ef
4
+ data.tar.gz: fdb98734b7873355e92d8c591c18d0f073686af0
5
5
  SHA512:
6
- metadata.gz: 1becb340432f945b10a1cab57bc07e0cfbe3fd581d6d79b743618733aecf4b613cb2be601f183b1f5b22b3b47a4c37db014f4e4261ac0051fdcd578db0f6a918
7
- data.tar.gz: 0ebfb10bbf10b26f28f2eac0bfbc5b6b58748e27119011dece8142a33db066426a383f4b8c54e144e3a48867c2ffbe48cbc6eced69f8535c0373e54678254cb2
6
+ metadata.gz: bd36979202c65e3dc9bf98b417b31abf3b57c2faa5e01cacde82a0852ac58ca9034722f43fa7194e5549ceda53b361b879c016816864caf24feee7e3ef88e9b2
7
+ data.tar.gz: 81c8f8705e16e86eea973f2ef8bbc0e9dec3f0b2cb3fd50668e97452d75c7c5b73477f252dcc679e63ed9b003dc6baa9d978fbfd94f1b65ba40af6fb0e6b9c81
data/.rubocop-todo.yml CHANGED
@@ -1,19 +1,28 @@
1
1
  # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-06-12 15:05:43 -0400 using RuboCop version 0.18.1.
2
+ # on 2014-10-06 19:48:04 -0400 using RuboCop version 0.18.1.
3
3
  # The point is for the user to remove these configuration records
4
4
  # one by one as the offences are removed from the code base.
5
5
  # Note that changes in the inspected code, or installation of new
6
6
  # versions of RuboCop, may require this file to be generated again.
7
7
 
8
- # Offence count: 41
8
+ # Offence count: 1
9
+ # Configuration parameters: CountComments.
10
+ ClassLength:
11
+ Max: 124
12
+
13
+ # Offence count: 3
14
+ CyclomaticComplexity:
15
+ Max: 13
16
+
17
+ # Offence count: 83
9
18
  Documentation:
10
19
  Enabled: false
11
20
 
12
- # Offence count: 57
21
+ # Offence count: 168
13
22
  LineLength:
14
23
  Max: 165
15
24
 
16
- # Offence count: 6
25
+ # Offence count: 34
17
26
  # Configuration parameters: CountComments.
18
27
  MethodLength:
19
- Max: 21
28
+ Max: 23
data/Gemfile CHANGED
@@ -5,4 +5,5 @@ gemspec
5
5
  gem "pry"
6
6
  gem "rake-notes"
7
7
  gem "simplecov"
8
- gem 'hashie', :git => 'https://github.com/intridea/hashie'
8
+ gem 'metric_fu'
9
+ gem 'inch'
data/README.md CHANGED
@@ -4,11 +4,27 @@ Polytrix is a polyglot test runner and documentation generator. It aims to let y
4
4
 
5
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
- 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.
7
+ A lot of Polytrix was influenced by and based on [test-kitchen](http://kitchen.ci/). Polytrix is attempting to do for multi-language testing of code samples what test-kitchen does for multi-platform testing of infrastructure code.
8
+
9
+ ## Features
10
+
11
+ - Validate sample code by running it through a series of stages:
12
+ * Clone: Fetch existing code samples from other git repos
13
+ * Detect: Match code samples for specific implementors to shared test scenarios
14
+ * Bootstrap: Install runtime dependencies for each implementor
15
+ * Exec: Invoke each test sample and capture the results (with built-in or custom spies)
16
+ * Validate: Ensure execution results (and data captured by spies) matches expectations
17
+ - Generate reports or documentation:
18
+ - A feature matrix comparing several implementations
19
+ - Detailed test reports showing validation results and data captured by spies
20
+ - Custom reports from custom spies
21
+ - Convert code samples to documentation
22
+ - Inject code samples and/or captured execution data into documentation templates
23
+ - Generate to-do lists for pending features
8
24
 
9
25
  ## Installing Polytrix
10
26
 
11
- Polytrix is distributed as a Ruby Gem. It should be installed using Bundler by adding this line to your Gemfile:
27
+ Polytrix is distributed as a Ruby Gem. It is ideally installed using Bundler by adding this line to your Gemfile:
12
28
 
13
29
  ```shell
14
30
  gem 'polytrix', '~> 0.1'
@@ -18,214 +34,160 @@ And then running `bundle install`.
18
34
 
19
35
  It can also be installed without Bundler by running `gem install polytrix`.
20
36
 
21
- ## Getting Help
37
+ **Note**: If installed with bundler it's best to always run `bundle exec polytrix ...` rather than just `polytrix ...`. The bundler documentation explains:
22
38
 
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.
39
+ > In some cases, running executables without `bundle exec` may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle.
40
+ >
41
+ > However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine.
24
42
 
25
- Note: You may need to prefix commands with `bundle exec` if you installed Polytrix using Bundler.
26
-
27
- If you need a quick reminder of what the `polytrix` command gives you, then use the **help** subcommand:
28
-
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
42
- ```
43
+ ## Usage
43
44
 
44
- ## The polytrix.yml file
45
+ ### Setup
45
46
 
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:
47
+ The Polytrix test suites are defined by `polytrix.yml`. This file defines the implementors you want to test and the test scenarios that they share. A simple Polytrix setup looks like this:
48
48
 
49
49
  ```yaml
50
- polytrix:
50
+ ---
51
51
  implementors:
52
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
53
+ language: 'ruby'
54
+ basedir: 'sdks/ruby'
64
55
  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'
56
+ language: 'java'
57
+ basedir: 'sdks/java'
58
+ python_samples:
59
+ language: 'python'
60
+ basedir: 'sdks/python'
70
61
 
62
+ global_env: # global_env defines input available for all scenarios
63
+ LOCALE: <%= ENV['LANG'] %> # templating is allowed
71
64
  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
65
+ Katas: # "Katas" is the name of the first test suite
66
+ samples: # Test scenarios within Katas
67
+ - hello world
68
+ - quine
69
+ Environment:
70
+ env: # Unlike global_env, these variables are only for the Katas suite
71
+ COLOR: red
72
+ samples:
73
+ - echo_color
96
74
  ```
97
75
 
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
76
+ The `implementors` defines the projects you want to test, and `suites` defines the test scenarios.
132
77
 
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 "$@"
78
+ ### CLI - Testing
79
+
80
+ Polytrix provides a CLI for driving tests, quickly viewing test results, or to generate test reports.
81
+
82
+ In order to see all available commands, simply run `bundle exec polytrix`:
83
+
84
+ ```bash
85
+ $ bundle exec polytrix
86
+
87
+ Commands:
88
+ polytrix bootstrap [INSTANCE|REGEXP|all] # Change scenario state to bootstraped. Running bootstrap scripts for the implementor
89
+ polytrix clone [INSTANCE|REGEXP|all] # Change scenario state to cloned. Clone the code sample from git
90
+ polytrix destroy [INSTANCE|REGEXP|all] # Change scenario state to destroyed. Delete all information for one or more scenarios
91
+ polytrix detect [INSTANCE|REGEXP|all] # Find sample code that matches a test scenario. Attempts to locate a code sample with a filename that the test scenario name.
92
+ polytrix exec [INSTANCE|REGEXP|all] # Change instance state to executed. Execute the code sample and capture the results.
93
+ polytrix help [COMMAND] # Describe available commands or one specific command
94
+ polytrix list [INSTANCE|REGEXP|all] # Lists one or more scenarios
95
+ polytrix report # Generate reports
96
+ polytrix show [INSTANCE|REGEXP|all] # Show detailed status for one or more scenarios
97
+ polytrix test [INSTANCE|REGEXP|all] # Test (clone, bootstrap, exec, and verify) one or more scenarios
98
+ polytrix verify [INSTANCE|REGEXP|all] # Change instance state to verified. Assert that the captured results match the expectations for the scenario.
99
+ polytrix version # Print Polytrix's version information
145
100
  ```
146
101
 
147
- ### Attaching Code Samples
102
+ The `INSTANCE` or `REGEXP` used in commands is matched against `Test ID`, which is an unique ID derived from the suite, scenario, and implementor names for a test. You can see the `Test ID`s via `polytrix show`.
148
103
 
149
- Polytrix tests are divided into suites, code samples, and scenarios. Each tuple (suite, code sample, scenario) is a test.
104
+ #### List and Show
150
105
 
151
- The structure used to define tests is:
106
+ The command `polytrix list [INSTANCE|REGEXP|all]` or `polytrix show [INSTANCE|REGEXP|all]` can be used to give you an overview (list) or detailed information (show) about all tests or a subset of tests.
152
107
 
153
- #### Suite Object
108
+ Initially the tests will have a status of "<Not Found>", but the status will change and details will become available as you run the commands below.
154
109
 
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
110
+ #### Cloning
161
111
 
162
- #### Code Sample Object
112
+ The command `polytrix clone [INSTANCE|REGEXP|all]` will fetch code samples for an implementor from a git repo. This step is skipped if no git repo is specified for the implementor, or if it already appears to be cloned.
163
113
 
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.
114
+ #### Bootstrapping
166
115
 
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.
116
+ The command `polytrix clone [INSTANCE|REGEXP|all]` will "bootstrap" the implementors.
169
117
 
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.
118
+ Bootstrapping ensures the implementor has the resources it needs to run samples, especially third-party libraries. Bootstrapping behavior is controlled by:
174
119
 
120
+ - The presence of a [bootstrap script](http://wynnnetherland.com/linked/2013012801/bootstrapping-consistency) in `script/bootstrap`
121
+ - A bootstrap command defined within the implementor in the `polytrix.yml`
122
+ - Default behavior for the implementors language
175
123
 
176
- #### Scenario Object
124
+ #### Detecting
177
125
 
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
126
+ The command `polytrix clone [INSTANCE|REGEXP|all]` will search each implementor for code samples that correspond with test scenarios.
184
127
 
185
- #### Example Suite Definition
128
+ Polytrix searches for samples by:
186
129
 
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
- ```
130
+ - Checking the implementor definition (in `polytrix.yml`) a static mapping of test scenarios to files.
131
+ - Searching files matching the scenario name, using a rather lax search pattern
132
+ - Search for a partial name match
133
+ - Case-insensitive
134
+ - Ignore ' ', '_', '-' and '.'
135
+ - Do not search files or directories that are .gitignore'd.
214
136
 
215
- ## Plugins
137
+ This search pattern achieves a good hit rate while still letting implementors follow language or pattern conventions. For example, if the scenario is called "create server", the following file names will all match:
216
138
 
217
- TBD
139
+ - src/java/com/foo/bar/CreateServer.java
140
+ - lib/foo/bar/create_server.rb
141
+ - samples/04-create-server.go
218
142
 
219
- ## Custom Validators
143
+ In order to avoid matching compiled files with similar names (like `CreateServer.class` or `create_server.pyc`) make sure they are gitignore'd.
220
144
 
221
- TBD
145
+ Successfully completing this stage will set a test's status to `Sample Found`.
222
146
 
223
- ## Usage
147
+ #### Executing
224
148
 
225
- ### Cloning implementors
226
- ### Bootstrapping implementors
227
- ### Executing scenarios
228
- ### Verifying scenario results
229
- ### Full test
149
+ The command `polytrix exec [INSTANCE|REGEXP|all]` will execute a code sample while capturing data via spies.
230
150
 
231
- ```
151
+ If the code sample is executable (e.g. many Bash, Ruby, or Python scripts) then Polytrix can execute it directly. If it is not direclty executable you can create a `script/wrapper`. Polytrix will execute the wrapper script with the first argument set to the path to the code sample. You can use this to defer to `bundle exec`, `node`, `java`, or any other program or script necessary to run the code sample.
152
+
153
+ Polytrix has a built-in spy to capture the processes exit status, stdout, and stderr. You can register custom spies to capture additional information. For example, a [Pacto](https://github.com/thoughtworks/pacto) spy has been used to capture HTTP requests that are made by code samples and match them to known services defined via [Swagger](http://swagger.io/).
154
+
155
+ TODO: Documentation on custom spies.
156
+
157
+ Successfully completing this stage will set a test's status to `Executed`.
158
+
159
+ #### Validating
160
+
161
+ The command `polytrix verify [INSTANCE|REGEXP|all]` will check the captured data from executing a code sample against the validators for that test scenario.
162
+
163
+ The validators are shared across all implementors, acting as a compliance test suite. A default validator is used if a test does not have any specific validators. A scenario can have more than one validator.
164
+
165
+ TODO: Documentation on writing validators.
166
+
167
+ This stage will set the test's status to `Partially Verified (n of m)` or `Fully Verified (n of n)`, where `n` is the number of validators that succeeded and `m` is the number of validators registered for the test scenario.
168
+
169
+ #### Cleaning
170
+
171
+ The command `polytrix destroy [INSTANCE|REGEXP|all]` clears out the saved test status and captured data.
172
+
173
+ This will set the status back to `<Not Found>`.
174
+
175
+ #### Testing
176
+
177
+ The command `polytrix test [INSTANCE|REGEXP|all]` combines the commands above into a single command. It runs in order:
178
+
179
+ destroy->detect->exec->verify
180
+
181
+ ### Reports
182
+
183
+ #### Dashboard
184
+
185
+ The command `polytrix report dashboard` will generate an HTML feature matrix where each result is a link to more information about the test execution.
186
+
187
+ #### Code2doc
188
+
189
+ The command `polytrix report code2doc [INSTANCE|REGEXP|all]` will convert annotated code samples to documentation. It is similar to projects like [docco](https://github.com/jashkenas/docco), except that it generates Markdown or reStructuredText rather than fully-styled HTML. The idea is that you can more easily drop these files into static site generators like [middlemanapp](http://middlemanapp.com/), documentation tools like [slate](https://github.com/tripit/slate), or services like [viewdocs](http://progrium.viewdocs.io/viewdocs) or [readthedocs](https://readthedocs.org/), which already handle styling and syntax highlighting.
190
+
191
+ ## Solo mode
192
+
193
+ TODO: Polytrix' experimental solo mode for running samples w/out a `polytrix.yml`.
data/Rakefile CHANGED
@@ -6,14 +6,14 @@ require 'cucumber'
6
6
  require 'cucumber/rake/task'
7
7
  require 'rubocop/rake_task'
8
8
 
9
- task :default => [:spec, :features, :self, :rubocop]
9
+ task default: [:spec, :features, :self, :rubocop]
10
10
 
11
11
  RSpec::Core::RakeTask.new('spec') do |t|
12
- t.rspec_opts = "-f documentation"
12
+ t.rspec_opts = '-f documentation'
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 -t ~@wip"
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'
@@ -24,17 +24,10 @@ end
24
24
 
25
25
  desc 'Self-test and self-document'
26
26
  task :self do
27
- sh 'bundle exec polytrix bootstrap'
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
27
+ sh 'bundle exec polytrix test'
35
28
  end
36
29
 
37
- Rubocop::RakeTask.new(:rubocop) do |task|
30
+ RuboCop::RakeTask.new(:rubocop) do |task|
38
31
  # abort rake on failure
39
32
  task.fail_on_error = true
40
33
  end
data/bin/polytrix CHANGED
@@ -2,5 +2,4 @@
2
2
  require 'polytrix/error'
3
3
  require 'polytrix/cli'
4
4
 
5
- $LOAD_PATH << 'spec'
6
5
  Polytrix.with_friendly_errors { Polytrix::CLI.start }
@@ -7,7 +7,6 @@ Feature: Boostrapping
7
7
  And the java SDK
8
8
  And the python SDK
9
9
  And the hello_world polytrix config
10
- And the standard rspec setup
11
10
  When I run `bundle exec polytrix bootstrap`
12
11
  Then the output should contain "-----> Bootstrapping java"
13
12
  Then the output should contain "-----> Bootstrapping python"
@@ -18,7 +17,6 @@ Feature: Boostrapping
18
17
  And the java SDK
19
18
  And the python SDK
20
19
  And the hello_world polytrix config
21
- And the standard rspec setup
22
20
  When I run `bundle exec polytrix bootstrap "(java|ruby)"`
23
21
  Then the output should contain "-----> Bootstrapping java"
24
22
  Then the output should not contain "-----> Bootstrapping python"
@@ -29,7 +27,6 @@ Feature: Boostrapping
29
27
  And the java SDK
30
28
  And the python SDK
31
29
  And the hello_world polytrix config
32
- And the standard rspec setup
33
30
  When I run `bundle exec polytrix bootstrap hello`
34
31
  Then the output should contain "-----> Bootstrapping java"
35
32
  Then the output should contain "-----> Bootstrapping python"
@@ -5,7 +5,6 @@ Feature: Cloning
5
5
 
6
6
  Scenario: Cloning all SDKs
7
7
  Given the hello_world polytrix config
8
- And the standard rspec setup
9
8
  When I run `bundle exec polytrix clone`
10
9
  Then the output should contain "-----> Cloning java"
11
10
  Then the output should contain "-----> Cloning python"
@@ -16,7 +15,6 @@ Feature: Cloning
16
15
  And the java SDK
17
16
  And the python SDK
18
17
  And the hello_world polytrix config
19
- And the standard rspec setup
20
18
  When I run `bundle exec polytrix clone "(java|ruby)"`
21
19
  Then the output should contain "-----> Cloning java"
22
20
  Then the output should not contain "-----> Cloning python"
@@ -27,7 +25,6 @@ Feature: Cloning
27
25
  And the java SDK
28
26
  And the python SDK
29
27
  And the hello_world polytrix config
30
- And the standard rspec setup
31
28
  When I run `bundle exec polytrix clone hello`
32
29
  Then the output should contain "-----> Cloning java"
33
30
  Then the output should contain "-----> Cloning python"
@@ -0,0 +1,38 @@
1
+ Feature: Show
2
+
3
+ Scenario: Initial state
4
+ Given the ruby SDK
5
+ And the java SDK
6
+ And the python SDK
7
+ And the hello_world polytrix config
8
+ When I run `bundle exec polytrix show katas-hello_world-ruby`
9
+ Then the output should contain:
10
+ """
11
+ katas-hello_world-ruby: <Not Found>
12
+ Test suite: Katas
13
+ Test scenario: hello world
14
+ Implementor: ruby
15
+ Source: sdks/ruby/challenges/hello_world.rb
16
+ Data from spies:
17
+ """
18
+
19
+ @no-clobber
20
+ Scenario: State after testing
21
+ Given I run `bundle exec polytrix test ruby`
22
+ When I run `bundle exec polytrix show katas-hello_world-ruby`
23
+ Then the output should contain:
24
+ """
25
+ katas-hello_world-ruby: Fully Verified (1 of 1)
26
+ Test suite: Katas
27
+ Test scenario: hello world
28
+ Implementor: ruby
29
+ Source: sdks/ruby/challenges/hello_world.rb
30
+ Execution result:
31
+ Exit Status: 0
32
+ Stdout:
33
+ Hello, world!
34
+ Stderr:
35
+ Validations:
36
+ default validator: ✓ Passed
37
+ Data from spies:
38
+ """
@@ -5,14 +5,13 @@ Feature: States
5
5
  And the java SDK
6
6
  And the python SDK
7
7
  And the hello_world polytrix config
8
- And the standard rspec setup
9
8
  When I run `bundle exec polytrix list`
10
9
  Then the output should contain:
11
10
  """
12
- Suite Scenario Implementor Status
13
- Katas hello world ruby <Not Found>
14
- Katas hello world java <Not Found>
15
- Katas hello world python <Not Found>
11
+ Test ID Suite Scenario Implementor Status
12
+ katas-hello_world-ruby Katas hello world ruby <Not Found>
13
+ katas-hello_world-java Katas hello world java <Not Found>
14
+ katas-hello_world-python Katas hello world python <Not Found>
16
15
  """
17
16
 
18
17
  @no-clobber
@@ -21,10 +20,10 @@ Feature: States
21
20
  When I run `bundle exec polytrix list`
22
21
  Then the output should contain:
23
22
  """
24
- Suite Scenario Implementor Status
25
- Katas hello world ruby <Not Found>
26
- Katas hello world java <Not Found>
27
- Katas hello world python Executed
23
+ Test ID Suite Scenario Implementor Status
24
+ katas-hello_world-ruby Katas hello world ruby <Not Found>
25
+ katas-hello_world-java Katas hello world java <Not Found>
26
+ katas-hello_world-python Katas hello world python Executed
28
27
  """
29
28
 
30
29
  @no-clobber
@@ -33,8 +32,8 @@ Feature: States
33
32
  When I run `bundle exec polytrix list`
34
33
  Then the output should contain:
35
34
  """
36
- Suite Scenario Implementor Status
37
- Katas hello world ruby Verified (x1)
38
- Katas hello world java <Not Found>
39
- Katas hello world python Executed
35
+ Test ID Suite Scenario Implementor Status
36
+ katas-hello_world-ruby Katas hello world ruby Fully Verified (1 of 1)
37
+ katas-hello_world-java Katas hello world java <Not Found>
38
+ katas-hello_world-python Katas hello world python Executed
40
39
  """
@@ -9,10 +9,6 @@ Given(/^the (\w+) polytrix config$/) do |config|
9
9
  FileUtils.cp_r "features/fixtures/configs/#{config}.yml", "#{current_dir}/polytrix.yml"
10
10
  end
11
11
 
12
- Given(/^the standard rspec setup$/) do
13
- FileUtils.cp_r 'features/fixtures/spec/', "#{current_dir}/"
14
- end
15
-
16
12
  Then(/^the file "(.*?)" should contain yaml matching:$/) do |file, content|
17
13
  in_current_dir do
18
14
  actual_content = YAML.load(File.read(file))