Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'fileutils'
- namespace :squish do
- desc 'Configure Squish environment for test run'
- # task :jenkins_setup => [:deploy_bw] do
- task :jenkins_setup do
- puts 'configure squish'
- if is_win?
- puts 'win blows!'
- JENKINS_WORKSPACE = ENV['JENKINS_WORKSPACE'] || 'c:\\\\data\\\\jenkins\\\\workspace\\\\NativeBooksmartWindows-Squish\\\\'
- puts JENKINS_WORKSPACE
- JENKINS_AUT = "#{JENKINS_WORKSPACE}Contents"
- puts JENKINS_AUT
- else
- puts 'for macs!'
- JENKINS_WORKSPACE = ENV['JENKINS_WORKSPACE'] || '/Users/bmitchell/src/native_booksmart/'
- puts JENKINS_WORKSPACE
- JENKINS_AUT = "#{JENKINS_WORKSPACE}Contents"
- puts JENKINS_AUT
- end
- # Now we need to update the squish server config that tells it where to find the application under test.
- # The path depends on the jenkins job name and path, which we pass in as args to this deploy script and replace into the settings file here
- system("sed -i.bak s@JENKINS_AUT_PATH@#{JENKINS_AUT}@g .squish/ver1/server.ini")
- if is_win?
- puts 'win blows!'
- puts 'Fix windows path escaping'
- # REM Fix up paths for windows, squish for some oddball reason wants double slashes in this pref file
- # sed -i.bak s@\\@\\\\@g .squish/ver1/server.ini
- end
- end
- desc 'get BW client'
- task :deploy_bw do
- BOOKSMART_BUILD_NAME = ENV['BOOKSMART_BUILD_NAME'] || 'NativeBooksmartWindows-Master'
- puts "Local deploy of latest BookWright from job: #{BOOKSMART_BUILD_NAME}"
- FileUtils.remove_dir(File.join('.', 'Contents'), true)
- FileUtils.rm_f File.join('.', 'native_booksmart_update.zip')
- puts "Begin download of BookWright client from http://jenkins.blurb.com/view/BookWright/job/#{BOOKSMART_BUILD_NAME}/lastSuccessfulBuild/artifact/dist/native_booksmart_update.zip"
- system("curl -L -s -f http://jenkins.blurb.com/view/BookWright/job/#{BOOKSMART_BUILD_NAME}/lastSuccessfulBuild/artifact/dist/native_booksmart_update.zip > native_booksmart_update.zip")
- puts "Download Complete! Begin Unzip"
- if is_win?
- puts "Windows Unzip"
- system("C:\\build_tools\\7zip\\7z.exe x native_booksmart_update.zip -aoa -o.\\Contents")
- else
- puts "Mac Unzip"
- system("unzip native_booksmart_update.zip -d Contents")
- end
- FileUtils.rm_f File.join('.', 'native_booksmart_update.zip')
- end
- desc 'Sort the Squish test cases alphabetically'
- task 'sort' do
- puts
- for suite_dir in SQUISH_SUITE_DIRS
- suite_conf = File.join(suite_dir, 'suite.conf')
- puts "Sorting the test cases in #{suite_conf}"
- test_cases = Dir[suite_dir + '/tst_*/'].map{|path| File.basename path}.sort_by{|name| name.downcase} # case-insensitive sort
- temp_file = Tempfile.new('suite.conf.mod')
- File.open(temp_file, 'w') do |outfile|
- for line in IO.readlines(suite_conf)
- line.sub! /^(TEST_CASES\s*=\s*)(.*)/, "\\1#{test_cases.join(' ')}"
- outfile.puts line
- end
- end
- FileUtils.mv temp_file, suite_conf
- end
- puts
- puts "Test cases sorted. Restart SquishIDE to see the changes."
- puts
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement