Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. require 'fileutils'
  2.  
  3. namespace :squish do
  4.  
  5. desc 'Configure Squish environment for test run'
  6. # task :jenkins_setup => [:deploy_bw] do
  7. task :jenkins_setup do
  8. puts 'configure squish'
  9. if is_win?
  10. puts 'win blows!'
  11. JENKINS_WORKSPACE = ENV['JENKINS_WORKSPACE'] || 'c:\\\\data\\\\jenkins\\\\workspace\\\\NativeBooksmartWindows-Squish\\\\'
  12. puts JENKINS_WORKSPACE
  13. JENKINS_AUT = "#{JENKINS_WORKSPACE}Contents"
  14. puts JENKINS_AUT
  15. else
  16. puts 'for macs!'
  17. JENKINS_WORKSPACE = ENV['JENKINS_WORKSPACE'] || '/Users/bmitchell/src/native_booksmart/'
  18. puts JENKINS_WORKSPACE
  19. JENKINS_AUT = "#{JENKINS_WORKSPACE}Contents"
  20. puts JENKINS_AUT
  21. end
  22.  
  23. # Now we need to update the squish server config that tells it where to find the application under test.
  24. # 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
  25. system("sed -i.bak s@JENKINS_AUT_PATH@#{JENKINS_AUT}@g .squish/ver1/server.ini")
  26.  
  27. if is_win?
  28. puts 'win blows!'
  29. puts 'Fix windows path escaping'
  30. # REM Fix up paths for windows, squish for some oddball reason wants double slashes in this pref file
  31. # sed -i.bak s@\\@\\\\@g .squish/ver1/server.ini
  32. end
  33. end
  34.  
  35. desc 'get BW client'
  36. task :deploy_bw do
  37. BOOKSMART_BUILD_NAME = ENV['BOOKSMART_BUILD_NAME'] || 'NativeBooksmartWindows-Master'
  38. puts "Local deploy of latest BookWright from job: #{BOOKSMART_BUILD_NAME}"
  39. FileUtils.remove_dir(File.join('.', 'Contents'), true)
  40. FileUtils.rm_f File.join('.', 'native_booksmart_update.zip')
  41.  
  42. puts "Begin download of BookWright client from http://jenkins.blurb.com/view/BookWright/job/#{BOOKSMART_BUILD_NAME}/lastSuccessfulBuild/artifact/dist/native_booksmart_update.zip"
  43. 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")
  44. puts "Download Complete! Begin Unzip"
  45.  
  46. if is_win?
  47. puts "Windows Unzip"
  48. system("C:\\build_tools\\7zip\\7z.exe x native_booksmart_update.zip -aoa -o.\\Contents")
  49. else
  50. puts "Mac Unzip"
  51. system("unzip native_booksmart_update.zip -d Contents")
  52. end
  53.  
  54. FileUtils.rm_f File.join('.', 'native_booksmart_update.zip')
  55. end
  56.  
  57. desc 'Sort the Squish test cases alphabetically'
  58. task 'sort' do
  59. puts
  60. for suite_dir in SQUISH_SUITE_DIRS
  61. suite_conf = File.join(suite_dir, 'suite.conf')
  62. puts "Sorting the test cases in #{suite_conf}"
  63.  
  64. test_cases = Dir[suite_dir + '/tst_*/'].map{|path| File.basename path}.sort_by{|name| name.downcase} # case-insensitive sort
  65.  
  66. temp_file = Tempfile.new('suite.conf.mod')
  67. File.open(temp_file, 'w') do |outfile|
  68. for line in IO.readlines(suite_conf)
  69. line.sub! /^(TEST_CASES\s*=\s*)(.*)/, "\\1#{test_cases.join(' ')}"
  70. outfile.puts line
  71. end
  72. end
  73.  
  74. FileUtils.mv temp_file, suite_conf
  75. end
  76. puts
  77. puts "Test cases sorted. Restart SquishIDE to see the changes."
  78. puts
  79. end
  80.  
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement