Skip to content

Commit

Permalink
tests cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
quix committed Sep 14, 2009
1 parent 537fac5 commit fef5c41
Show file tree
Hide file tree
Showing 37 changed files with 526 additions and 362 deletions.
352 changes: 312 additions & 40 deletions devel/jumpstart.rb

Large diffs are not rendered by default.

67 changes: 0 additions & 67 deletions devel/jumpstart/attr_lazy.rb

This file was deleted.

44 changes: 0 additions & 44 deletions devel/jumpstart/ruby.rb

This file was deleted.

85 changes: 0 additions & 85 deletions devel/jumpstart/simple_installer.rb

This file was deleted.

35 changes: 0 additions & 35 deletions devel/jumpstart/util.rb

This file was deleted.

3 changes: 1 addition & 2 deletions install.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,2 @@
$LOAD_PATH.unshift "devel" load './devel/jumpstart.rb'
require 'jumpstart/simple_installer'
Jumpstart::SimpleInstaller.new.run Jumpstart::SimpleInstaller.new.run
27 changes: 27 additions & 0 deletions lib/quix/instance_eval_with_args.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,27 @@

module Quix
module InstanceEvalWithArgs
module_function

def with_temp_method(instance, method_name, method_block)
(class << instance ; self ; end).class_eval do
define_method(method_name, &method_block)
begin
yield method_name
ensure
remove_method(method_name)
end
end
end

def call_temp_method(instance, method_name, *args, &method_block)
with_temp_method(instance, method_name, method_block) {
instance.send(method_name, *args)
}
end

def instance_eval_with_args(instance, *args, &block)
call_temp_method(instance, :__temp_method, *args, &block)
end
end
end
62 changes: 40 additions & 22 deletions lib/quix/ruby.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,11 @@


require 'rbconfig'

module Quix module Quix
module Ruby module Ruby
EXECUTABLE = lambda { module_function

def executable
require 'rbconfig'

name = File.join( name = File.join(
Config::CONFIG["bindir"], Config::CONFIG["bindir"],
Config::CONFIG["RUBY_INSTALL_NAME"] Config::CONFIG["RUBY_INSTALL_NAME"]
Expand All @@ -15,30 +17,46 @@ module Ruby
else else
name name
end end
}.call end


class << self def run(*args)
def run(*args) cmd = [executable, *args]
cmd = [EXECUTABLE, *args] unless system(*cmd)
unless system(*cmd) cmd_str = cmd.map { |t| "'#{t}'" }.join(", ")
cmd_str = cmd.map { |t| "'#{t}'" }.join(", ") raise "system(#{cmd_str}) failed with status #{$?.exitstatus}"
raise "system(#{cmd_str}) failed with status #{$?.exitstatus}"
end
end end

end
def with_warnings(value = true)
previous = $VERBOSE def run_code_and_capture(code)
$VERBOSE = value IO.popen(%{"#{executable}"}, "r+") { |pipe|
begin pipe.print(code)
yield pipe.flush
ensure pipe.close_write
$VERBOSE = previous pipe.read
end }
end

def run_file_and_capture(file)
unless File.file? file
raise "file does not exist: `#{file}'"
end end
IO.popen(%{"#{executable}" "#{file}"}, "r") { |pipe|
pipe.read
}
end


def no_warnings(&block) def with_warnings(value = true)
with_warnings(nil, &block) previous = $VERBOSE
$VERBOSE = value
begin
yield
ensure
$VERBOSE = previous
end end
end end

def no_warnings(&block)
with_warnings(nil, &block)
end
end end
end end
2 changes: 1 addition & 1 deletion test/array_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + "/common" require File.dirname(__FILE__) + '/quix_test_base'


require "quix/ext/array" require "quix/ext/array"


Expand Down
2 changes: 1 addition & 1 deletion test/attr_lazy_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + "/common" require File.dirname(__FILE__) + '/quix_test_base'


require 'quix/attr_lazy' require 'quix/attr_lazy'


Expand Down
2 changes: 1 addition & 1 deletion test/attr_scope_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + "/common" require File.dirname(__FILE__) + '/quix_test_base'


require "quix/attr_scope" require "quix/attr_scope"


Expand Down
2 changes: 1 addition & 1 deletion test/casefold_glob_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + "/common" require File.dirname(__FILE__) + '/quix_test_base'


require "fileutils" require "fileutils"
require "quix/casefold_glob" require "quix/casefold_glob"
Expand Down
2 changes: 1 addition & 1 deletion test/class_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + "/common" require File.dirname(__FILE__) + '/quix_test_base'


require 'quix/ext/class' require 'quix/ext/class'


Expand Down
Loading

0 comments on commit fef5c41

Please sign in to comment.