specwrk 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/specwrk/cli.rb +3 -1
- data/lib/specwrk/client.rb +2 -0
- data/lib/specwrk/version.rb +1 -1
- data/lib/specwrk/web/endpoints.rb +3 -1
- data/lib/specwrk/worker/executor.rb +3 -0
- data/lib/specwrk/worker.rb +13 -0
- data/lib/specwrk.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d9511529ad6b58048312d287ed54240cffd3918b5621555f59c54b69b9451b4
|
4
|
+
data.tar.gz: a1a878eff39f2ae7592c37572195d1a7da5268554004df4966a6adba559f75e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc0f1e302994fc815d00e409d86536acc3589baeb77d4e765741c061a0b0942ae93902ac64940cb5a9aeb5828d899982b67fd13b3e6ac1ffa6252d5efb8139ed
|
7
|
+
data.tar.gz: e789547dab6d911d1d69c244b87043fb48842380eeac948952b016e6d4f9e7b7e1d9daf8ce96428b1d1902bcb32c4054e52b048d454c51bc4622f3ac241e72c5
|
data/lib/specwrk/cli.rb
CHANGED
@@ -37,11 +37,13 @@ module Specwrk
|
|
37
37
|
base.unique_option :id, type: :string, default: "specwrk-worker", desc: "The identifier for this worker. Default specwrk-worker(-COUNT_INDEX)."
|
38
38
|
base.unique_option :count, type: :integer, default: 1, aliases: ["-c"], desc: "The number of worker processes you want to start. Default 1."
|
39
39
|
base.unique_option :output, type: :string, default: ENV.fetch("SPECWRK_OUT", ".specwrk/"), aliases: ["-o"], desc: "Directory where worker output is stored. Overrides SPECWRK_OUT. Default '.specwrk/'."
|
40
|
+
base.unique_option :seed_waits, type: :integer, default: ENV.fetch("SPECWRK_SEED_WAITS", "10"), aliases: ["-w"], desc: "Number of times the worker will wait for examples to be seeded to the server. 1sec between attempts. Overrides SPECWRK_SEED_WAITS. Default '10'."
|
40
41
|
end
|
41
42
|
|
42
|
-
on_setup do |id:, count:, output:, **|
|
43
|
+
on_setup do |id:, count:, output:, seed_waits:, **|
|
43
44
|
ENV["SPECWRK_ID"] = id
|
44
45
|
ENV["SPECWRK_COUNT"] = count.to_s
|
46
|
+
ENV["SPECWRK_SEED_WAITS"] = seed_waits.to_s
|
45
47
|
ENV["SPECWRK_OUT"] = Pathname.new(output).expand_path(Dir.pwd).to_s
|
46
48
|
FileUtils.mkdir_p(ENV["SPECWRK_OUT"])
|
47
49
|
end
|
data/lib/specwrk/client.rb
CHANGED
data/lib/specwrk/version.rb
CHANGED
@@ -94,7 +94,9 @@ module Specwrk
|
|
94
94
|
|
95
95
|
if @examples.length.positive?
|
96
96
|
[200, {"Content-Type" => "application/json"}, [JSON.generate(@examples)]]
|
97
|
-
elsif processing_queue.length.zero?
|
97
|
+
elsif pending_queue.length.zero? && processing_queue.length.zero? && completed_queue.length.zero?
|
98
|
+
[204, {"Content-Type" => "text/plain"}, ["Waiting for sample to be seeded."]]
|
99
|
+
elsif completed_queue.length.positive? && processing_queue.length.zero?
|
98
100
|
[410, {"Content-Type" => "text/plain"}, ["That's a good lad. Run along now and go home."]]
|
99
101
|
else
|
100
102
|
not_found
|
@@ -11,6 +11,8 @@ require "specwrk/worker/null_formatter"
|
|
11
11
|
module Specwrk
|
12
12
|
class Worker
|
13
13
|
class Executor
|
14
|
+
attr_reader :example_processed
|
15
|
+
|
14
16
|
def failure
|
15
17
|
completion_formatter.failure
|
16
18
|
end
|
@@ -27,6 +29,7 @@ module Specwrk
|
|
27
29
|
reset!
|
28
30
|
|
29
31
|
example_ids = examples.map { |example| example[:id] }
|
32
|
+
@example_processed ||= true unless example_ids.size.zero? # only ever toggle from nil => true
|
30
33
|
|
31
34
|
options = RSpec::Core::ConfigurationOptions.new rspec_options + example_ids
|
32
35
|
RSpec::Core::Runner.new(options).run($stderr, $stdout)
|
data/lib/specwrk/worker.rb
CHANGED
@@ -17,6 +17,7 @@ module Specwrk
|
|
17
17
|
@running = true
|
18
18
|
@client = Client.new
|
19
19
|
@executor = Executor.new
|
20
|
+
@seed_waits = ENV.fetch("SPECWRK_SEED_WAITS", "10").to_i
|
20
21
|
@heartbeat_thread ||= Thread.new do
|
21
22
|
thump
|
22
23
|
end
|
@@ -36,6 +37,17 @@ module Specwrk
|
|
36
37
|
# This will cause workers to 'hang' until all work has been completed
|
37
38
|
# TODO: break here if all the other worker processes on this host are done executing examples
|
38
39
|
sleep 0.5
|
40
|
+
rescue WaitingForSeedError
|
41
|
+
@seed_wait_count ||= 0
|
42
|
+
@seed_wait_count += 1
|
43
|
+
|
44
|
+
if @seed_wait_count <= @seed_waits
|
45
|
+
warn "No examples seeded yet, waiting..."
|
46
|
+
sleep 1
|
47
|
+
else
|
48
|
+
warn "No examples seeded, giving up!"
|
49
|
+
break
|
50
|
+
end
|
39
51
|
end
|
40
52
|
|
41
53
|
executor.final_output.tap(&:rewind).each_line { |line| $stdout.write line }
|
@@ -88,6 +100,7 @@ module Specwrk
|
|
88
100
|
attr_reader :running, :client, :executor
|
89
101
|
|
90
102
|
def status
|
103
|
+
return 1 unless executor.example_processed
|
91
104
|
return 1 if executor.failure
|
92
105
|
return 1 if Specwrk.force_quit
|
93
106
|
|
data/lib/specwrk.rb
CHANGED
@@ -8,6 +8,7 @@ module Specwrk
|
|
8
8
|
# HTTP Client Errors
|
9
9
|
ClientError = Class.new(Error)
|
10
10
|
UnhandledResponseError = Class.new(ClientError)
|
11
|
+
WaitingForSeedError = Class.new(ClientError)
|
11
12
|
NoMoreExamplesError = Class.new(ClientError)
|
12
13
|
CompletedAllExamplesError = Class.new(ClientError)
|
13
14
|
|