Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add convention to preload app before first child is forked in a slave…

…. The convention is that a file called testjour_preload.rb will get loaded if it exists.
  • Loading branch information...
commit eca3ecc646a873faf7f3d2820784e5ca5269f672 1 parent 091a8ee
Luke Melia and Lee Bankewitz authored
View
7 features/run.feature
@@ -48,4 +48,9 @@ Feature: Run Features
Then it should fail with "1 steps passed"
And the output should contain "FAIL"
And the output should contain "1 steps failed"
- And it should run on 2 slaves
+ And it should run on 2 slaves
+
+ Scenario: Preload application
+ Given a file testjour_preload.rb at the root of the project that logs "Hello, world"
+ When I run `testjour passing.feature`
+ And testjour.log should include "Hello, world"
View
6 features/step_definitions/testjour_steps.rb
@@ -19,6 +19,12 @@
FileUtils.mkdir_p full_path
end
+Given /^a file testjour_preload.rb at the root of the project that logs "Hello, world"$/ do
+ File.open(File.join(@full_dir, 'testjour_preload.rb'), 'w') do |file|
+ file.puts "Testjour.logger.info 'Hello, world'"
+ end
+end
+
When /^I run `testjour (.+)`$/ do |args|
@args ||= []
@args += args.split
View
1  features/support/env.rb
@@ -13,5 +13,6 @@ def be_like(expected)
Dir.chdir(@full_dir) do
File.unlink("testjour.log") if File.exists?("testjour.log")
+ File.unlink("testjour_preload.rb") if File.exists?("testjour_preload.rb")
end
end
View
10 lib/testjour/commands/run_slave.rb
@@ -27,6 +27,7 @@ def execute
configuration.setup
configuration.setup_mysql
require_cucumber_files
+ preload_app
work
rescue Object => ex
Testjour.logger.error "run:slave error: #{ex.message}"
@@ -45,7 +46,7 @@ def work
features = load_plain_text_features(feature_file)
parent_pid = $PID
if @child = fork
- Testjour.logger.info "Forked #{@child} at #{Time.now.to_i}"
+ Testjour.logger.info "Forked #{@child} to run #{feature_file}"
Process.wait
Testjour.logger.info "Finished running: #{feature_file}"
else
@@ -74,6 +75,13 @@ def require_cucumber_files
step_mother.load_code_files(configuration.cucumber_configuration.step_defs_to_load)
end
+ def preload_app
+ if File.exist?('./testjour_preload.rb')
+ Testjour.logger.info 'Requiring ./testjour_preload.rb'
+ require './testjour_preload.rb'
+ end
+ end
+
# Not every platform supports fork. Here we do our magic to
# determine if yours does.
def fork
View
1  spec/fixtures/testjour_preload.rb
@@ -0,0 +1 @@
+Testjour.logger.info 'Hello, world'
Please sign in to comment.
Something went wrong with that request. Please try again.