From 25cd38f01025e1da8ed3ec97515961cc0005fbc0 Mon Sep 17 00:00:00 2001 From: Laurent Sansonetti Date: Sat, 6 Oct 2012 16:20:02 +0200 Subject: [PATCH] load UIAutomation dynamically, add 'spec:device' task which runs the specs on the device --- lib/motion/project.rb | 20 ++++++++++++++++---- lib/motion/project/builder.rb | 6 ++++-- lib/motion/project/config.rb | 8 +++----- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/motion/project.rb b/lib/motion/project.rb index 55cf31d0..09e95c70 100644 --- a/lib/motion/project.rb +++ b/lib/motion/project.rb @@ -116,10 +116,22 @@ namespace :archive do end end -desc "Run the test/spec suite" -task :spec do - App.config.spec_mode = true - Rake::Task["simulator"].invoke +desc "Same as 'spec:simulator'" +task :spec => ['spec:simulator'] + +namespace :spec do + desc "Run the test/spec suite on the simulator" + task :simulator do + App.config.spec_mode = true + Rake::Task["simulator"].invoke + end + + desc "Run the test/spec suite on the device" + task :device do + App.config.spec_mode = true + ENV['debug'] ||= '1' + Rake::Task["device"].invoke + end end desc "Deploy on the device" diff --git a/lib/motion/project/builder.rb b/lib/motion/project/builder.rb index 8e451ce7..9eabd812 100644 --- a/lib/motion/project/builder.rb +++ b/lib/motion/project/builder.rb @@ -289,6 +289,9 @@ EOS } } + // Load the UIAutomation framework. + dlopen("/Developer/Library/PrivateFrameworks/UIAutomation.framework/UIAutomation", RTLD_LOCAL); + SpecLauncher *launcher = [[self alloc] init]; [[NSNotificationCenter defaultCenter] addObserver:launcher selector:@selector(appLaunched:) name:UIApplicationDidBecomeActiveNotification object:nil]; return launcher; @@ -370,10 +373,9 @@ EOS or File.mtime(File.join(datadir, platform, 'libmacruby-static.a')) > File.mtime(main_exec) App.info 'Link', main_exec objs_list = objs.map { |path, _| path }.unshift(init_o, main_o, *config.frameworks_stubs_objects(platform)).map { |x| "\"#{x}\"" }.join(' ') - framework_search_paths = config.framework_search_paths.map { |x| "-F#{File.expand_path(x)}" }.join(' ') frameworks = config.frameworks_dependencies.map { |x| "-framework #{x}" }.join(' ') weak_frameworks = config.weak_frameworks.map { |x| "-weak_framework #{x}" }.join(' ') - sh "#{cxx} -o \"#{main_exec}\" #{objs_list} #{config.ldflags(platform)} -L#{File.join(datadir, platform)} -lmacruby-static -lobjc -licucore #{framework_search_paths} #{frameworks} #{weak_frameworks} #{config.libs.join(' ')} #{vendor_libs.map { |x| '-force_load "' + x + '"' }.join(' ')}" + sh "#{cxx} -o \"#{main_exec}\" #{objs_list} #{config.ldflags(platform)} -L#{File.join(datadir, platform)} -lmacruby-static -lobjc -licucore #{frameworks} #{weak_frameworks} #{config.libs.join(' ')} #{vendor_libs.map { |x| '-force_load "' + x + '"' }.join(' ')}" main_exec_created = true end diff --git a/lib/motion/project/config.rb b/lib/motion/project/config.rb index 5f5b5cb6..96076ac4 100644 --- a/lib/motion/project/config.rb +++ b/lib/motion/project/config.rb @@ -322,9 +322,8 @@ EOS end deps.uniq! if @framework_search_paths.empty? - deps.select! { |dep| File.exist?(File.join(datadir, 'BridgeSupport', dep + '.bridgesupport')) } + deps = deps.select { |dep| File.exist?(File.join(datadir, 'BridgeSupport', dep + '.bridgesupport')) } end - deps << 'UIAutomation' if spec_mode deps end end @@ -351,6 +350,7 @@ EOS end end end + deps << 'UIAutomation' if spec_mode bs_files end end @@ -448,9 +448,7 @@ EOS end def common_flags(platform) - cflags = "#{arch_flags(platform)} -isysroot \"#{sdk(platform)}\" -miphoneos-version-min=#{deployment_target} -F#{sdk(platform)}/System/Library/Frameworks" - cflags << " -F#{sdk(platform)}/Developer/Library/PrivateFrameworks" if spec_mode # For UIAutomation - cflags + "#{arch_flags(platform)} -isysroot \"#{sdk(platform)}\" -miphoneos-version-min=#{deployment_target} -F#{sdk(platform)}/System/Library/Frameworks" end def cflags(platform, cplusplus)