Permalink
Browse files

added tasks to rakefile to setup cucumber test env., added phony web …

…server for testing, fixed bug in config_file.global on first creation, add now prepends to path, install folders will be capitalized, mingw folders won't have '-1386-mingw' on the end.
  • Loading branch information...
unknown
unknown committed Oct 25, 2009
1 parent eed0e75 commit 74b77276e64bddc5ff9dc0839c0338fa0c1d298e
View
@@ -1,6 +1,7 @@
# -*- ruby -*-
require 'rubygems'
+require 'win32/process'
file 'tools/pik/pik.exy' do
Dir.chdir 'tools/pik' do
@@ -74,8 +75,60 @@ end
require 'cucumber'
require 'cucumber/rake/task'
+namespace :cucumber do
+
+ directory "C:/temp"
+
+ desc "sets up C:\\temp for pik's cuke tests"
+ task :setup => "C:/temp" do
+ ENV['HOME'] = "C:\\temp"
+ sh "pik config installs=\"C:\\temp\\more spaces in path\\ruby\""
+ sh "pik install jruby"
+ sh "pik install ironruby"
+ sh "pik install ruby"
+ sh "pik install ruby 1.8"
+ end
+
+ namespace :phonyweb do
+
+ task :start => 'hosts:add' do
+ @web = Process.create(:app_name => "ruby C:\\scripts\\repo\\pik\\phony_web\\server.rb")
+ end
+
+ task :kill => 'hosts:remove' do
+ Process.kill(3, @web.process_id)
+ end
+ end
+
+ # this is used with the phony web server for
+ # testing the install and list command
+ # without sucking up bandwidth. It also makes the
+ # tests run faster
+ namespace :hosts do
+
+ HOSTS = File.join(ENV['SystemRoot'], 'System32','drivers','etc','hosts')
+ desc "adds fake hosts to system's hosts file"
+ task :add do
+ File.open(HOSTS,'a+'){|f|
+ f.puts "127.0.0.1 www.jruby.org rubyforge.org www.rubyforge.org jruby.kenai.com dist.codehaus.org"
+ }
+ end
+
+ desc "remove fake hosts from system's hosts file"
+ task :remove do
+ new_hosts = File.open(HOSTS, 'r').readlines.reject{ |i| i =~ /^127\.0\.0\.1 www\.jruby\.org/ }
+ File.open(HOSTS, 'w+'){|f| f.puts new_hosts }
+ end
+
+ task :rm => :remove
+
+ end
+end
+
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features -f html -o ../pik_cucumber.html -f progress"
end
+task :cuke => ['cucumber:phonyweb:start', :features, 'cucumber:phonyweb:kill']
+
# vim: syntax=Ruby
@@ -29,8 +29,8 @@ Feature: add command
Scenario: add a version with spaces in the path.
Given I have an empty config.yml
- When I run "pik add "C:\temp\more spaces in path\ruby\jruby_140RC1\bin""
- Then I should see "Adding: 140: jruby 1.4.0RC1 (ruby 1.8.7 patchlevel 174)"
- And I should see "Located at: C:\temp\more spaces in path\ruby\jruby_140RC1\bin"
+ When I run "pik add "C:\temp\more spaces in path\ruby\jruby-140RC2\bin""
+ Then I should see "Adding: 140: jruby 1.4.0RC2 (ruby 1.8.7 patchlevel 174)"
+ And I should see "Located at: C:\temp\more spaces in path\ruby\jruby-140RC2\bin"
View
@@ -2,19 +2,19 @@
---
"091: IronRuby 0.9.1.0 on .NET 2.0.0.0":
:path: !ruby/object:Pathname
- path: c:/temp/more spaces in path/ruby/ironruby_091/bin
-"140: jruby 1.4.0RC1 (ruby 1.8.7 patchlevel 174) (2009-09-30 80c263b) (Java HotSpot(TM) Client VM 1.6.0_14) [x86-java]":
+ path: c:/temp/more spaces in path/ruby/ironruby-091/bin
+"140: jruby 1.4.0RC2 (ruby 1.8.7 patchlevel 174) (2009-10-21 7e77f32) (Java HotSpot(TM) Client VM 1.6.0_14) [x86-java]":
:path: !ruby/object:Pathname
- path: C:/temp/more spaces in path/ruby/jruby_140RC1/bin
+ path: C:/temp/more spaces in path/ruby/jruby-140RC2/bin
"186: ruby 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32]":
:path: !ruby/object:Pathname
path: c:/ruby/186-p368-mingw32/bin
"186: ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]":
:path: !ruby/object:Pathname
- path: c:/temp/more spaces in path/ruby/ruby_186-p383/bin
+ path: c:/temp/more spaces in path/ruby/ruby-186-p383/bin
"191: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]":
:path: !ruby/object:Pathname
- path: c:/temp/more spaces in path/ruby/ruby_191-p243/bin
+ path: c:/temp/more spaces in path/ruby/ruby-191-p243/bin
---
:download_dir: !ruby/object:Pathname
path: C:\\temp\\path with spaces\\downloads
@@ -10,3 +10,20 @@ Feature: install command
And I should see " to: C:\temp\path with spaces\downloads"
And I should see "** Extracting: C:\temp\path with spaces\downloads"
And I should see "** Adding: 191: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]"
+
+
+ Scenario: install IronRuby
+ When I run "pik in ironruby"
+ Then I should see "** Downloading: http://rubyforge.org/frs/download.php/64504/ironruby-0.9.1.zip"
+ And I should see " to: C:\temp\path with spaces\downloads\ironruby-0.9.1.zip"
+ And I should see "** Extracting: C:\temp\path with spaces\downloads\ironruby-0.9.1.zip"
+ And I should see "** Adding: 091: IronRuby 0.9.1.0 on .NET 2.0.0.0"
+ And I should see " Located at: C:\temp\path with spaces\IronRuby-091\bin"
+
+ Scenario: install Ruby 1.8.6
+ When I run "pik in ruby 1.8"
+ Then I should see "** Downloading: http://rubyforge.org/frs/download.php/62267/ruby-1.8.6-p383-i386-mingw32.7z"
+ And I should see " to: C:\temp\path with spaces\downloads\ruby-1.8.6-p383-i386-mingw32.7z"
+ And I should see "** Extracting: C:\temp\path with spaces\downloads\ruby-1.8.6-p383-i386-mingw32.7z"
+ And I should see "** Adding: 186: ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]"
+ And I should see " Located at: C:\temp\path with spaces\Ruby-186-p383\bin"
@@ -24,4 +24,4 @@ Feature: list command
And I should see "JRuby:"
And I should see "1.4.0RC2:"
Then I should see "Ruby:"
- And I should see " 1.8.6-p383-i386-mingw32:"
+ And I should see " 1.8.6-p383"
@@ -14,7 +14,7 @@ Feature: switch command
Examples:
| version | patterns |
| IronRuby 0.9.1.0 on .NET 2.0.0.0 | Ir 91 |
- | jruby 1.4.0RC1 (ruby 1.8.7 patchlevel 174) | jruby 1.4 |
+ | jruby 1.4.0RC2 (ruby 1.8.7 patchlevel 174) | jruby 1.4 |
| ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32] | 186 383 |
| ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32] | 191 p2 |
@@ -27,7 +27,7 @@ Feature: switch command
Examples:
| version | patterns |
| IronRuby 0.9.1.0 on .NET 2.0.0.0 | Ir 91 |
- | jruby 1.4.0RC1 (ruby 1.8.7 patchlevel 174) | jruby 1.4 |
+ | jruby 1.4.0RC2 (ruby 1.8.7 patchlevel 174) | jruby 1.4 |
| ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32] | 186 383 |
| ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32] | 191 p2 |
@@ -17,9 +17,9 @@ def initialize(args=ARGV, config_=nil)
end
def execute
- implementation = @args.shift
- target, package = Implementations[implementation].find(*@args)
- target = @install_root + "#{implementation}-#{target.gsub('.','')}"
+ implementation = Implementations[@args.shift]
+ target, package = implementation.find(*@args)
+ target = @install_root + "#{implementation.subclass}-#{target.gsub('.','')}"
file = download(package)
extract(target, file)
add( Pathname(target) + 'bin' )
View
@@ -8,13 +8,14 @@ class ConfigFile < Hash
def initialize
@file = File.join(PIK_HOME, 'config.yml')
+ @global = {}
super
if File.exists? @file
contents = File.read( @file )
unless contents.empty?
documents = YAML.load_stream( contents )
self.update( documents[0] )
- @global = documents[1] || {}
+ @global.update( documents[1] ) if documents[1]
end
end
end
@@ -2,12 +2,12 @@
class Pathname
def to_s
- @path.gsub('/','\\')
+ @path.tr('/','\\')
end
alias to_windows to_s
def to_ruby
- @path.gsub('\\','/')
+ @path.tr('\\','/')
end
def ruby
@@ -75,7 +75,7 @@ class Ruby < Base
def initialize
super
@path = "/frs/?group_id=167"
- @re = /\"(.+ruby\-(.+)\.7z)\"/
+ @re = /\"(.+ruby\-(.+)\-i386\-mingw32\.7z)\"/
end
end
View
@@ -34,7 +34,7 @@ def each
def add(new_path)
new_path = Pathname(new_path)
- @path << new_path.to_windows.to_s
+ @path.unshift new_path.to_windows.to_s
self
end
Oops, something went wrong.

0 comments on commit 74b7727

Please sign in to comment.