summaryrefslogtreecommitdiff
path: root/features/step_definitions
diff options
context:
space:
mode:
authorAlex Coles <alex@alexcolesportfolio.com>2009-12-07 00:02:19 -0300
committerLuis Lavena <luislavena@gmail.com>2009-12-07 00:02:19 -0300
commit3f2743234235279bf0ce7e3b6e5ac96603c94bcc (patch)
treedcb130a3c745752bb500c5a920595b03b4377571 /features/step_definitions
parentf729a4bcd7ecbb4b45cc77b60625779ffedfabd4 (diff)
downloadrake-compiler-3f2743234235279bf0ce7e3b6e5ac96603c94bcc.tar.gz
Sync Java compilation scenarios
Merged Java compilation scenarios with minor adjustments to exclude non-POSIX OS.
Diffstat (limited to 'features/step_definitions')
-rw-r--r--features/step_definitions/compilation.rb16
-rw-r--r--features/step_definitions/cross_compilation.rb9
-rw-r--r--features/step_definitions/execution.rb33
-rw-r--r--features/step_definitions/gem.rb12
-rw-r--r--features/step_definitions/java_compilation.rb7
5 files changed, 65 insertions, 12 deletions
diff --git a/features/step_definitions/compilation.rb b/features/step_definitions/compilation.rb
index 35e72dd..bc2638a 100644
--- a/features/step_definitions/compilation.rb
+++ b/features/step_definitions/compilation.rb
@@ -8,6 +8,11 @@ Given /^a extension cross-compilable '(.*)'$/ do |extension_name|
generate_source_code_for extension_name
end
+Given /^a extension Java-compilable '(.*)'$/ do |extension_name|
+ generate_java_compile_extension_task_for extension_name
+ generate_java_source_code_for extension_name
+end
+
Given /^a extension '(.*)' multi cross\-compilable$/ do |extension_name|
generate_multi_cross_compile_extension_task_for extension_name
generate_source_code_for extension_name
@@ -23,12 +28,23 @@ Given /^that all my source files are in place$/ do
Given "a extension cross-compilable 'extension_one'"
end
+Given /^that all my Java source files are in place$/ do
+ Given "a safe project directory"
+ Given "a extension Java-compilable 'extension_one'"
+end
+
Given /^that my gem source is all in place$/ do
Given "a safe project directory"
Given "a gem named 'gem_abc'"
Given "a extension cross-compilable 'extension_one'"
end
+Given /^that my JRuby gem source is all in place$/ do
+ Given "a safe project directory"
+ Given "a gem named 'gem_abc'"
+ Given "a extension Java-compilable 'extension_one'"
+end
+
Given /^that my gem source is all in place to target two platforms$/ do
Given "a safe project directory"
Given "a gem named 'gem_abc'"
diff --git a/features/step_definitions/cross_compilation.rb b/features/step_definitions/cross_compilation.rb
index 5262275..9851cce 100644
--- a/features/step_definitions/cross_compilation.rb
+++ b/features/step_definitions/cross_compilation.rb
@@ -6,14 +6,7 @@ Given %r{^I'm running a POSIX operating system$} do
end
Given %r{^I've installed cross compile toolchain$} do
- compilers = %w(i586-mingw32msvc-gcc i386-mingw32-gcc)
- paths = ENV['PATH'].split(File::PATH_SEPARATOR)
- compiler = compilers.find do |comp|
- paths.find do |path|
- File.exist? File.join(path, comp)
- end
- end
- pending "Cannot locate suitable compiler in the PATH." unless compiler
+ pending 'Cannot locate suitable compiler in the PATH.' unless search_path(%w(i586-mingw32msvc-gcc i386-mingw32-gcc))
end
Then /^binaries for platform '(.*)' get generated$/ do |platform|
diff --git a/features/step_definitions/execution.rb b/features/step_definitions/execution.rb
index 43a3bff..b45a076 100644
--- a/features/step_definitions/execution.rb
+++ b/features/step_definitions/execution.rb
@@ -1,15 +1,25 @@
-Given %r{^I've already successfully executed rake task '(.*)'$} do |task_name|
- emptyness = `rake #{task_name} 2>&1`
+# FIXME: Make the Transform work
+#
+# Transform /^| on JRuby$/ do |step_arg|
+# / on JRuby/.match(step_arg) != nil
+# end
+
+Given %r{^I've already successfully executed rake task '(.*)'(| on JRuby)$} do |task_name, on_jruby|
+ rake_cmd = "rake #{task_name}"
+ rake_cmd = 'jruby -S ' << rake_cmd if on_jruby == ' on JRuby'
+ emptyness = `#{rake_cmd} 2>&1`
unless $?.success?
warn emptyness
raise "rake failed with #{$?.exitstatus}"
end
end
-When /^rake task '(.*)' is invoked$/ do |task_name|
+When /^rake task '(.*)' is invoked(| on JRuby)$/ do |task_name, on_jruby|
@output ||= {}
@result ||= {}
- @output[task_name] = `rake #{task_name} 2>&1`
+ rake_cmd = "rake #{task_name}"
+ rake_cmd = 'jruby -S ' << rake_cmd if on_jruby == ' on JRuby'
+ @output[task_name] = `#{rake_cmd} 2>&1`
@result[task_name] = $?.success?
end
@@ -21,6 +31,14 @@ Then /^rake task '(.*)' succeeded$/ do |task_name|
end
end
+Then /^rake task '(.*)' should fail$/ do |task_name|
+ if @result.nil? || !@result.include?(task_name) then
+ raise "The task #{task_name} should be invoked first."
+ else
+ @result[task_name].should be_false
+ end
+end
+
Then /^output of rake task '(.*)' (contains|do not contain) \/(.*)\/$/ do |task_name, condition, regex|
if condition == 'contains' then
@output[task_name].should match(%r(#{regex}))
@@ -28,3 +46,10 @@ Then /^output of rake task '(.*)' (contains|do not contain) \/(.*)\/$/ do |task_
@output[task_name].should_not match(%r(#{regex}))
end
end
+
+Then /^output of rake task '(.*)' warns$/ do |task_name, warning|
+ STDERR.puts task_name.inspect
+ STDERR.puts @output[task_name].inspect
+ STDERR.puts warning.inspect
+ @output[task_name].should include(warning)
+end
diff --git a/features/step_definitions/gem.rb b/features/step_definitions/gem.rb
index afa9ea1..b241cd6 100644
--- a/features/step_definitions/gem.rb
+++ b/features/step_definitions/gem.rb
@@ -12,6 +12,12 @@ end
Then /^a gem for '(.*)' version '(.*)' platform '(.*)' do exist in '(.*)'$/ do |name, version, platform, folder|
File.exist?(gem_file_platform(folder, name, version, platform)).should be_true
+
+ # unpack the Gem and check what's inside!
+ `gem unpack #{gem_file_platform(folder, name, version, platform)} --target tmp`
+ unpacked_gem_dir = unpacked_gem_dir_platform('tmp', name, version, platform)
+ File.exist?(unpacked_gem_dir).should be_true
+ Dir.glob(unpacked_gem_dir << "/lib/*.#{binary_extension(platform)}").should_not be_empty
end
Then /^gem for platform '(.*)' get generated$/ do |platform|
@@ -28,3 +34,9 @@ def gem_file_platform(folder, name, version, platform = nil)
file << ".gem"
file
end
+
+def unpacked_gem_dir_platform(folder, name, version, platform = nil)
+ file = "#{folder}/#{name}-#{version}"
+ file << "-" << (platform || Gem::Platform.new(RUBY_PLATFORM).to_s)
+ file
+end
diff --git a/features/step_definitions/java_compilation.rb b/features/step_definitions/java_compilation.rb
new file mode 100644
index 0000000..16868b5
--- /dev/null
+++ b/features/step_definitions/java_compilation.rb
@@ -0,0 +1,7 @@
+Given %r{^I've installed the Java Development Kit$} do
+ pending('Cannot locate suitable Java compiler (the Java Development Kit) in the PATH.') unless search_path(%w(javac javac.exe))
+end
+
+Given %r{^I've installed JRuby$} do
+ pending('Cannot locate a JRuby installation in the PATH.') unless search_path(%w(jruby jruby.exe jruby.bat))
+end