diff --git a/lib/abusetheforce.rb b/lib/abusetheforce.rb index 6ebec20..399ee75 100644 --- a/lib/abusetheforce.rb +++ b/lib/abusetheforce.rb @@ -83,18 +83,26 @@ module AbuseTheForce end end - def self.deploy_project(dpath=Atf_Config.get_project_path) + def self.deploy_test(dpath, test_name) + + options = { :run_tests => [ test_name ], :rollback_on_error => true } + + deploy_project(dpath, options) + end + + def self.deploy_project(dpath=Atf_Config.get_project_path, options={ :rollback_on_error => true }) if @client == nil build_client end if File.file? File.join(dpath, 'package.xml') - @client.deploy(File.expand_path(dpath), { :rollback_on_error => true }). + @client.deploy(File.expand_path(dpath), options). on_complete { |job| puts "Finished deploy #{job.id}!" result = job.result if result != nil + puts "\nDeploy #{result.success ? "SUCCESS" : "FAILURE"}" # If a failed deploy, print errors @@ -105,16 +113,38 @@ module AbuseTheForce result.messages = [].push result.messages end - puts "ERRORS: #{result.messages.size}" + puts "DEPLOY ERRORS: #{result.messages.reject { |m| m.success }.size}" result.messages.each do |m| + # If the path is not from the project, fix it unless m.file_name.starts_with? Atf_Config.src m.file_name = m.file_name.sub(/[a-zA-Z._-]*\//, Atf_Config.src + '/') end # Print our error in teh format "filename:line:column type in object message" - puts "#{m.file_name}:#{m.line_number}:#{m.column_number} #{m.problem_type} in #{m.full_name} #{m.problem}" + if !m.success + puts "#{m.file_name}:#{m.line_number}:#{m.column_number} #{m.problem_type} in #{m.full_name} #{m.problem}" + end + end + + # Need messages in an array + if result.run_test_result != nil + unless result.run_test_result.failures.kind_of? Array + result.run_test_result.failures = [].push result.run_test_result.failures + end + + puts "TESTS RUN: #{result.run_test_result.num_tests_run} FAILURES: #{result.run_test_result.num_failures}" + + result.run_test_result.failures.each do |m| + + # Print our error in teh format "filename:line:column type in object message" + if !m.success + puts "#{m.name}.#{m.method_name}: #{m.message}" + puts "Stack Trace: #{m.stack_trace}" + puts "" + end + end end end end diff --git a/lib/abusetheforce/cli.rb b/lib/abusetheforce/cli.rb index 666bebf..dd82aff 100644 --- a/lib/abusetheforce/cli.rb +++ b/lib/abusetheforce/cli.rb @@ -256,6 +256,37 @@ module AbuseTheForce end end + desc "test ", "Deploy and execute a test class" + long_desc <<-LONG_DESC + Deploys file at path to the active target and executes tests in that class. + + If test fails changes are rolled back + LONG_DESC + def test(fpath) + + AbuseTheForce.clean_temp + + AbuseTheForce.copy_temp_file fpath + + # If a new target was provided, switch to it + if options[:target] != nil + AbuseTheForce.temp_switch_target options[:target] + end + + # Get path to temp project directory + temp_path = File.join(Atf_Config.root_dir, TEMP_DIR) + + test_name = File.basename fpath, '.*' + + # Deploy + AbuseTheForce.deploy_test temp_path, test_name + + # if using a temp target, switch back + if options[:target] != nil + AbuseTheForce.temp_switch_target + end + end + desc "list ", "Deploy a list of files" long_desc <<-LONG_DESC Parameter is a path a file containing a realtive list of files to be deployed. diff --git a/lib/abusetheforce/version.rb b/lib/abusetheforce/version.rb index 398dcf3..190cf3e 100644 --- a/lib/abusetheforce/version.rb +++ b/lib/abusetheforce/version.rb @@ -1,3 +1,3 @@ module AbuseTheForce - VERSION = '0.1.0' + VERSION = '0.1.2' end