Skip to content

Commit

Permalink
installed rbiphonetest
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Sep 4, 2008
1 parent c5f6eb7 commit cefb771
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .autotest
@@ -0,0 +1,18 @@
class String
def underscore
gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
downcase
end
end

Autotest.add_hook :initialize do |at|
at.add_mapping(/Classes\/(.*)\.[mh]/) do |_, m|
["test/test_#{m[1].underscore}.rb"]
end
end

Autotest.add_hook :run_command do |at|
system "rake compile"
end
40 changes: 40 additions & 0 deletions Rakefile
@@ -0,0 +1,40 @@
require "rubygems"
require "rake"

Dir['tasks/**/*.rake'].each { |rake| load rake }

namespace :objc do
desc "Compiles all Objective-C bundles for testing"
task :compile
end

task :compile => "objc:compile"

namespace :objc do
# look for Classes/*.m files containing a line "void Init_ClassName"
# These are the primary classes for bundles; make a bundle for each
model_file_paths = `find Classes/*.m -exec grep -l "^void Init_" {} \\;`.split("\n")
model_file_paths.each do |path|
path =~ /Classes\/(.*)\.m/
model_name = $1

task :compile => model_name do
if Dir.glob("**/#{model_name}.bundle").length == 0
STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
STDERR.puts "Bundle actually failed to build."
STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit(1)
end
end

task model_name.to_sym => "build/bundles/#{model_name}.bundle"

file "build/bundles/#{model_name}.bundle" => ["Classes/#{model_name}.m", "Classes/#{model_name}.h"] do |t|
FileUtils.mkdir_p "build/bundles"
FileUtils.rm Dir["build/bundles/#{model_name}.bundle"]
sh "gcc -o build/bundles/#{model_name}.bundle -bundle -framework Foundation Classes/#{model_name}.m"
end
end

end

14 changes: 14 additions & 0 deletions script/destroy
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))

begin
require 'rubigen'
rescue LoadError
require 'rubygems'
require 'rubigen'
end
require 'rubigen/scripts/destroy'

ARGV.shift if ['--help', '-h'].include?(ARGV[0])
RubiGen::Base.use_component_sources! [:rbiphonetest, :iphone, :test_unit]
RubiGen::Scripts::Destroy.new.run(ARGV)
14 changes: 14 additions & 0 deletions script/generate
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))

begin
require 'rubigen'
rescue LoadError
require 'rubygems'
require 'rubigen'
end
require 'rubigen/scripts/generate'

ARGV.shift if ['--help', '-h'].include?(ARGV[0])
RubiGen::Base.use_component_sources! [:rbiphonetest, :iphone, :test_unit]
RubiGen::Scripts::Generate.new.run(ARGV)
11 changes: 11 additions & 0 deletions tasks/test_unit.rake
@@ -0,0 +1,11 @@
require "rake/testtask"

task :default => :test

task :test => :compile

Rake::TestTask.new do |t|
t.libs << "test" << "test/bundles"
t.test_files = FileList['test/test*.rb']
t.verbose = true
end
4 changes: 4 additions & 0 deletions test/test_helper.rb
@@ -0,0 +1,4 @@
require "test/unit"
require "osx/cocoa"

$:.unshift File.dirname(__FILE__) + "/../build/bundles"

0 comments on commit cefb771

Please sign in to comment.