polytrix 0.1.0.pre → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -2,53 +2,14 @@ module Polytrix
2
2
  describe Configuration do
3
3
  subject(:configuration) { Configuration.new }
4
4
 
5
- it 'creates a logger' do
6
- expect(configuration.logger).to be_kind_of ::Logger
7
- end
8
-
9
- describe '.test_manifest' do
5
+ describe '.manifest' do
10
6
  it 'parses the YAML file and registers the manifest' do
11
- original_manifest = configuration.test_manifest
12
- configuration.test_manifest = 'spec/fixtures/polytrix_tests.yml'
13
- new_manifest = configuration.test_manifest
7
+ original_manifest = configuration.manifest
8
+ configuration.manifest = 'spec/fixtures/polytrix.yml'
9
+ new_manifest = configuration.manifest
14
10
  expect(original_manifest).to_not eq(new_manifest)
15
11
  expect(new_manifest).to(be_an_instance_of(Polytrix::Manifest))
16
12
  end
17
13
  end
18
-
19
- describe '.implementor' do
20
- context 'argument is a Hash' do
21
- it 'creates and registers Implementors' do
22
- # This'd be a bit nicer w/ rspec 3...
23
- expect do
24
- configuration.implementor name: 'test', basedir: '.'
25
- end.to change {
26
- configuration.implementors
27
- }.from(be_empty).to be_an_instance_of(Array)
28
-
29
- expect(configuration.implementors.first).to be_an_instance_of Polytrix::Implementor
30
- expect(configuration.implementors.first.name).to eq('test')
31
- end
32
- end
33
- context 'argument is a String' do
34
- context 'directory exists' do
35
- context 'polytrix.yml does not exist' do
36
- it 'builds an implementor with default settings' do
37
- implementor = configuration.implementor('samples/sdks/ruby')
38
- expect(implementor).to be_an_instance_of(Polytrix::Implementor)
39
- expect(implementor.name).to eq('ruby') # directory name
40
- end
41
- end
42
-
43
- context 'polytrix_tests.yml exists' do
44
- it 'loads settings from polytrix.yml' do
45
- implementor = configuration.implementor('samples/sdks/custom')
46
- expect(implementor).to be_an_instance_of(Polytrix::Implementor)
47
- expect(implementor.name).to eq('My Custom project')
48
- end
49
- end
50
- end
51
- end
52
- end
53
14
  end
54
15
  end
@@ -78,7 +78,7 @@ module Polytrix
78
78
 
79
79
  describe '#code_block' do
80
80
  it 'generates markdown code blocks by default' do
81
- expected = "```ruby\n" + source + "\n```\n"
81
+ expected = "\n```ruby\n" + source + "\n```\n\n"
82
82
  code_block = challenge.code_block(challenge.source, 'ruby')
83
83
  expect(code_block).to eq(expected)
84
84
  end
@@ -46,9 +46,11 @@ module Polytrix
46
46
  expect(generator.code2doc(source_file, 'ruby')).to eq(
47
47
  <<-eos.gsub(/^( |\t)+/, '')
48
48
  Comments are documentation
49
+
49
50
  ```ruby
50
51
  puts 'And this is a code block'
51
52
  ```
53
+
52
54
  eos
53
55
  )
54
56
  end
@@ -2,20 +2,62 @@ require 'spec_helper'
2
2
 
3
3
  module Polytrix
4
4
  describe Implementor do
5
- subject(:implementor) { described_class.new(name: 'test', language: 'ruby', basedir: 'sdks/test') }
5
+ subject(:implementor) { described_class.new(name: 'test', language: 'ruby', basedir: expected_sdk_dir) }
6
+ let(:expected_sdk_dir) { 'samples/sdks/foo' }
6
7
  let(:executor) { double('executor') }
8
+ let(:expected_sdk_path) { Pathname.new(File.absolute_path(expected_sdk_dir)) }
7
9
 
8
10
  before do
9
11
  subject.executor = executor
10
12
  end
11
13
 
12
14
  describe '#bootstrap' do
15
+ # Need an implementor that's already cloned
16
+ let(:expected_sdk_dir) { 'samples/sdks/ruby' }
17
+
13
18
  it 'executes script/bootstrap' do
14
- expect(executor).to receive(:execute).with('./scripts/bootstrap', cwd: Pathname.new(File.absolute_path('sdks/test')), prefix: 'test')
19
+ expect(executor).to receive(:execute).with('./scripts/bootstrap', cwd: expected_sdk_path, prefix: 'test')
15
20
  implementor.bootstrap
16
21
  end
17
22
  end
18
23
 
24
+ describe '#clone' do
25
+ it 'does nothing if there is no clone option' do
26
+ expect(executor).to_not receive(:execute)
27
+ implementor.clone
28
+
29
+ implementor.clone
30
+ end
31
+
32
+ context 'with git as a simple string' do
33
+ it 'clones the repo specified by the string' do
34
+ implementor.git = 'git@github.com/foo/bar'
35
+ expect(executor).to receive(:execute).with("git clone git@github.com/foo/bar -b master #{expected_sdk_path}", {})
36
+ implementor.clone
37
+ end
38
+ end
39
+
40
+ context 'with git as a hash' do
41
+ it 'clones the repo specified by the repo parameter' do
42
+ implementor.git = { repo: 'git@github.com/foo/bar' }
43
+ expect(executor).to receive(:execute).with("git clone git@github.com/foo/bar -b master #{expected_sdk_path}", {})
44
+ implementor.clone
45
+ end
46
+
47
+ it 'clones the repo on the branch specified by the brach parameter' do
48
+ implementor.git = { repo: 'git@github.com/foo/bar', branch: 'quuz' }
49
+ expect(executor).to receive(:execute).with("git clone git@github.com/foo/bar -b quuz #{expected_sdk_path}", {})
50
+ implementor.clone
51
+ end
52
+
53
+ it 'clones the repo to the location specified by the to parameter' do
54
+ implementor.git = { repo: 'git@github.com/foo/bar', to: 'sdks/foo' }
55
+ expect(executor).to receive(:execute).with('git clone git@github.com/foo/bar -b master sdks/foo', {})
56
+ implementor.clone
57
+ end
58
+ end
59
+ end
60
+
19
61
  describe '#build_challenge' do
20
62
  subject(:implementor) { Polytrix::Implementor.new name: 'some_sdk', basedir: File.absolute_path('spec/fixtures') }
21
63
  let(:challenge) { Fabricate(:challenge, name: 'factorial', vars: {}) }
@@ -1,14 +1,14 @@
1
1
  module Polytrix
2
2
  describe Manifest do
3
3
  describe '#from_yaml' do
4
- subject(:manifest) { described_class.from_yaml 'spec/fixtures/polytrix_tests.yml' }
4
+ subject(:manifest) { described_class.from_yaml 'spec/fixtures/polytrix.yml' }
5
5
 
6
6
  it 'initializes a manifest' do
7
7
  expect(manifest).to be_an_instance_of Polytrix::Manifest
8
8
  end
9
9
 
10
10
  it 'processes ERB' do
11
- expect(manifest.global_env['LOCALE']).to eq(ENV['LANG'])
11
+ expect(manifest.global_env.LOCALE).to eq(ENV['LANG'])
12
12
  end
13
13
 
14
14
  it 'parses global_env' do
@@ -16,12 +16,15 @@ module Polytrix
16
16
  end
17
17
 
18
18
  it 'parses suites' do
19
- expect(manifest.suites).to be_an_instance_of Polytrix::Manifest::Suites
19
+ expect(manifest.suites).to be_an_instance_of Hashie::Hash
20
+ manifest.suites.each_value do | suite |
21
+ expect(suite).to be_an_instance_of Polytrix::Manifest::Suite
22
+ end
20
23
  end
21
24
 
22
25
  describe '#find_suite' do
23
26
  before(:each) do
24
- Polytrix.configuration.test_manifest = 'samples/polytrix_tests.yml'
27
+ Polytrix.configuration.manifest = 'samples/polytrix.yml'
25
28
  end
26
29
  it 'returns nil if no suite matches' do
27
30
  suite = subject.find_suite('none')
@@ -2,23 +2,21 @@ require 'spec_helper'
2
2
 
3
3
  describe Polytrix do
4
4
  describe '.find_implementor' do
5
+ before do
6
+ Polytrix.configuration.manifest = 'samples/polytrix.yml'
7
+ end
8
+
5
9
  it 'returns nil if no implementor is found for the file' do
6
10
  tempfile = Tempfile.new(['foo', '.java'])
7
11
  expect(described_class.find_implementor tempfile.path).to be_nil
8
12
  end
9
13
 
10
- it 'finds implementors from polytrix.yml in parent directories' do
11
- sample_file = 'samples/sdks/custom/challenges/HelloWorld.custom'
12
- implementor = described_class.find_implementor sample_file
13
- expect(implementor).to be_an_instance_of Polytrix::Implementor
14
- expect(implementor.name).to eq('My Custom project')
15
- end
16
-
17
14
  it 'finds implementors from by matching basedir to an already loaded implementor' do
18
- Polytrix.configuration.implementor(
19
- name: 'java',
20
- basedir: 'samples/sdks/java'
21
- )
15
+ Polytrix.manifest.implementors['java'] = Fabricate(:implementor, name: 'java', basedir: 'samples/sdks/java')
16
+ # Polytrix.configuration.implementor(
17
+ # name: 'java',
18
+ # basedir: 'samples/sdks/java'
19
+ # )
22
20
 
23
21
  sample_file = 'samples/sdks/java/challenges/HelloWorld.java'
24
22
  implementor = described_class.find_implementor sample_file
data/spec/thor_spy.rb CHANGED
@@ -43,6 +43,8 @@ class ThorSpy
43
43
  b.unshift("#{b.shift}: #{e.message} (#{e.class})")
44
44
  @stderr.puts(b.map { |s| "\tfrom #{s}" }.join("\n"))
45
45
  1
46
+ rescue SystemExit => e
47
+ e.status
46
48
  ensure
47
49
  # ...then we put them back.
48
50
  $stderr = STDERR
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polytrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Lincoln
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-01 00:00:00.000000000 Z
11
+ date: 2014-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: logging
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: mixlib-shellout
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,20 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: buff-shell_out
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: middleware
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +100,14 @@ dependencies:
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: '2.1'
103
+ version: '3.0'
76
104
  type: :runtime
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: '2.1'
110
+ version: '3.0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: padrino-helpers
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -190,17 +218,21 @@ files:
190
218
  - docs/samples/code2doc/python/hello_world.md
191
219
  - docs/samples/code2doc/python/quine.md
192
220
  - docs/samples/code2doc/ruby/hello_world.md
221
+ - features/bootstrapping.feature
222
+ - features/cloning.feature
193
223
  - features/execution.feature
194
224
  - features/fixtures/configs/empty.yml
195
225
  - features/fixtures/configs/hello_world.yml
196
- - features/fixtures/spec/polytrix_merge.rb
197
226
  - features/fixtures/spec/polytrix_spec.rb
198
- - features/reporting.feature
227
+ - features/solo.feature
228
+ - features/states.feature
199
229
  - features/step_definitions/sdk_steps.rb
200
230
  - features/support/env.rb
201
231
  - lib/polytrix.rb
202
232
  - lib/polytrix/challenge.rb
233
+ - lib/polytrix/challenge_result.rb
203
234
  - lib/polytrix/challenge_runner.rb
235
+ - lib/polytrix/challenges.rb
204
236
  - lib/polytrix/cli.rb
205
237
  - lib/polytrix/cli/add.rb
206
238
  - lib/polytrix/cli/report.rb
@@ -208,26 +240,41 @@ files:
208
240
  - lib/polytrix/cli/reports/json_reporter.rb
209
241
  - lib/polytrix/cli/reports/markdown_reporter.rb
210
242
  - lib/polytrix/cli/reports/yaml_reporter.rb
243
+ - lib/polytrix/color.rb
244
+ - lib/polytrix/command.rb
245
+ - lib/polytrix/command/action.rb
246
+ - lib/polytrix/command/list.rb
247
+ - lib/polytrix/command/rundoc.rb
248
+ - lib/polytrix/command/test.rb
211
249
  - lib/polytrix/configuration.rb
212
250
  - lib/polytrix/core/file_system_helper.rb
251
+ - lib/polytrix/core/hashie.rb
213
252
  - lib/polytrix/core/implementor.rb
253
+ - lib/polytrix/core/manifest_section.rb
254
+ - lib/polytrix/core/string_helpers.rb
214
255
  - lib/polytrix/documentation/code_segmenter.rb
215
256
  - lib/polytrix/documentation/comment_styles.rb
216
257
  - lib/polytrix/documentation/helpers/code_helper.rb
217
258
  - lib/polytrix/documentation/view_helper.rb
218
259
  - lib/polytrix/documentation_generator.rb
219
- - lib/polytrix/executor.rb
260
+ - lib/polytrix/error.rb
220
261
  - lib/polytrix/logger.rb
262
+ - lib/polytrix/logging.rb
221
263
  - lib/polytrix/manifest.rb
222
264
  - lib/polytrix/result.rb
223
265
  - lib/polytrix/rspec.rb
224
266
  - lib/polytrix/rspec/documentation_formatter.rb
225
267
  - lib/polytrix/rspec/yaml_report.rb
268
+ - lib/polytrix/runners/buff_shellout_executor.rb
269
+ - lib/polytrix/runners/executor.rb
226
270
  - lib/polytrix/runners/linux_challenge_runner.rb
227
271
  - lib/polytrix/runners/middleware/change_directory.rb
228
272
  - lib/polytrix/runners/middleware/feature_executor.rb
229
273
  - lib/polytrix/runners/middleware/setup_env_vars.rb
274
+ - lib/polytrix/runners/mixlib_shellout_executor.rb
230
275
  - lib/polytrix/runners/windows_challenge_runner.rb
276
+ - lib/polytrix/state_file.rb
277
+ - lib/polytrix/util.rb
231
278
  - lib/polytrix/validation.rb
232
279
  - lib/polytrix/validations.rb
233
280
  - lib/polytrix/validator.rb
@@ -235,17 +282,16 @@ files:
235
282
  - lib/polytrix/version.rb
236
283
  - polytrix.gemspec
237
284
  - polytrix.rb
238
- - polytrix_tests.yml
285
+ - polytrix.yml
239
286
  - resources/code_sample.tt
240
287
  - samples/.gitignore
241
288
  - samples/_markdown.md
242
289
  - samples/default_bootstrap.rb
243
290
  - samples/polytrix.rb
291
+ - samples/polytrix.yml
244
292
  - samples/polytrix_cli.sh
245
- - samples/polytrix_tests.yml
246
293
  - samples/scripts/bootstrap
247
294
  - samples/scripts/wrapper
248
- - samples/sdks/custom/polytrix.yml
249
295
  - samples/sdks/java/.gitignore
250
296
  - samples/sdks/java/build.gradle
251
297
  - samples/sdks/java/challenges/HelloWorld.java
@@ -260,10 +306,11 @@ files:
260
306
  - scripts/bootstrap
261
307
  - scripts/wrapper
262
308
  - spec/fabricators/challenge_fabricator.rb
309
+ - spec/fabricators/implementor_fabricator.rb
263
310
  - spec/fabricators/manifest_fabricator.rb
264
311
  - spec/fabricators/validator_fabricator.rb
265
312
  - spec/fixtures/factorial.py
266
- - spec/fixtures/polytrix_tests.yml
313
+ - spec/fixtures/polytrix.yml
267
314
  - spec/fixtures/src-doc/_scenario.md.erb
268
315
  - spec/fixtures/src-doc/quine.md.erb
269
316
  - spec/polytrix/challenge_runner_spec.rb
@@ -298,9 +345,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
298
345
  version: '0'
299
346
  required_rubygems_version: !ruby/object:Gem::Requirement
300
347
  requirements:
301
- - - ">"
348
+ - - ">="
302
349
  - !ruby/object:Gem::Version
303
- version: 1.3.1
350
+ version: '0'
304
351
  requirements: []
305
352
  rubyforge_project:
306
353
  rubygems_version: 2.2.0
@@ -308,19 +355,22 @@ signing_key:
308
355
  specification_version: 4
309
356
  summary: A polyglot test runner for sample code
310
357
  test_files:
358
+ - features/bootstrapping.feature
359
+ - features/cloning.feature
311
360
  - features/execution.feature
312
361
  - features/fixtures/configs/empty.yml
313
362
  - features/fixtures/configs/hello_world.yml
314
- - features/fixtures/spec/polytrix_merge.rb
315
363
  - features/fixtures/spec/polytrix_spec.rb
316
- - features/reporting.feature
364
+ - features/solo.feature
365
+ - features/states.feature
317
366
  - features/step_definitions/sdk_steps.rb
318
367
  - features/support/env.rb
319
368
  - spec/fabricators/challenge_fabricator.rb
369
+ - spec/fabricators/implementor_fabricator.rb
320
370
  - spec/fabricators/manifest_fabricator.rb
321
371
  - spec/fabricators/validator_fabricator.rb
322
372
  - spec/fixtures/factorial.py
323
- - spec/fixtures/polytrix_tests.yml
373
+ - spec/fixtures/polytrix.yml
324
374
  - spec/fixtures/src-doc/_scenario.md.erb
325
375
  - spec/fixtures/src-doc/quine.md.erb
326
376
  - spec/polytrix/challenge_runner_spec.rb
@@ -1,5 +0,0 @@
1
- require 'polytrix'
2
-
3
- File.open('reports/polytrix.yaml', 'wb') do |f|
4
- f.write Polytrix.merge_results(ARGV)
5
- end
@@ -1,140 +0,0 @@
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
- """
@@ -1,89 +0,0 @@
1
- require 'hashie/dash'
2
- require 'thor'
3
-
4
- module Polytrix
5
- module Executor
6
- class OutputDecorator
7
- # Reserve :red, :black, :white
8
- COLORS = [:green, :yellow, :blue, :magenta, :cyan]
9
-
10
- def self.next_color
11
- @next_color ||= 0
12
- @next_color += 1
13
- COLORS[@next_color % COLORS.size]
14
- end
15
-
16
- def initialize(real_io, prefix = nil)
17
- @real_io = real_io
18
- # @prefix = set_color(prefix, :cyan)
19
- @prefix = "#{prefix}: " if prefix
20
- @color = self.class.next_color
21
- @thor_shell = Thor::Shell::Color.new
22
- end
23
-
24
- def puts(line)
25
- line = line.gsub(/^/, @prefix) if @prefix
26
- @real_io.puts @thor_shell.set_color(line, @color)
27
- end
28
-
29
- def <<(line)
30
- line = line.gsub(/^/, @prefix) if @prefix
31
- @real_io << @thor_shell.set_color(line, @color)
32
- end
33
-
34
- def method_missing(meth, *args, &block)
35
- @real_io.send meth, *args, &block
36
- end
37
- end
38
-
39
- class ExecutionError < StandardError
40
- attr_accessor :execution_result
41
- end
42
-
43
- class ExecutionResult < Hashie::Dash
44
- property :exitstatus, require: true
45
- property :stdout, required: true
46
- property :stderr, required: true
47
- end
48
-
49
- class InteractiveExecutor
50
- def execute(command, opts)
51
- system command
52
- # FIXME: This needs to return execution result, if interactive remains supported
53
- end
54
- end
55
-
56
- class ShellOutExecutor
57
- def execute(command, opts)
58
- prefix = opts.delete :prefix
59
- shell = Mixlib::ShellOut.new(command, opts)
60
- shell.live_stream = OutputDecorator.new($stdout, prefix) unless Polytrix.configuration.suppress_output
61
- shell.run_command
62
- execution_result = ExecutionResult.new exitstatus: shell.exitstatus, stdout: shell.stdout, stderr: shell.stderr
63
- begin
64
- shell.error!
65
- rescue Mixlib::ShellOut::ShellCommandFailed => e
66
- execution_error = ExecutionError.new(e)
67
- execution_error.execution_result = execution_result
68
- raise execution_error
69
- end
70
-
71
- execution_result
72
- end
73
- end
74
-
75
- attr_writer :executor
76
-
77
- def executor
78
- @executor ||= if ENV['INTERACTIVE']
79
- InteractiveExecutor.new
80
- else
81
- ShellOutExecutor.new
82
- end
83
- end
84
-
85
- def execute(command, opts = {})
86
- executor.execute(command, opts)
87
- end
88
- end
89
- end
@@ -1,2 +0,0 @@
1
- ---
2
- name: My Custom project