Skip to content

Instantly share code, notes, and snippets.

@KrauseFx
Created November 1, 2014 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KrauseFx/fda87474855dfe0051e6 to your computer and use it in GitHub Desktop.
Save KrauseFx/fda87474855dfe0051e6 to your computer and use it in GitHub Desktop.
This script runs through all the devices and generates a HTML page, viewing all the images
require 'JSON'
class Runner
def Runner.run
system("xcodebuild clean")
config = {
"devices": [
"iPhone 6 Plus (8.1 Simulator)",
"iPhone 6 (8.1 Simulator)",
"iPhone 5s (8.1 Simulator)",
"iPhone 4s (8.1 Simulator)"
],
"languages": [
"de"
],
"ios_version": "8.1"
}
app_id = File.read("./Resources/appID.txt").to_i
devices = config["devices"]
languages = config["languages"]
ios_version = config["ios_version"]
output_path = ENV["output"] || "./reports/"
output_path = "#{output_path}/#{app_id}"
project = "GCSpecs"
scheme = "Integration"
FileUtils.rm_rf(output_path)
run = 0
languages.each do |language|
# Switch the language by editing the xcscheme
path = "./#{project}.xcodeproj/xcshareddata/xcschemes/#{scheme}.xcscheme"
content = File.read(path).gsub(/AppleLanguages\ \(..\)/, "AppleLanguages (#{language})")
File.write(path, content)
sleep 2
puts `open "/Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app"`
sleep 2
devices.each do |device|
puts "Running on #{device} in language #{language}"
run_output = "#{output_path}/#{run}"
FileUtils.mkdir_p(run_output)
`killall "Instruments"`
`killall "iOS Simulator"`
`killall "xcodebuild"`
`killall "subliminal-instrument"`
command = "
\"./Pods/Subliminal/Supporting Files/CI/subliminal-test\" \
-workspace \"#{project}.xcworkspace\" \
-scheme \"#{scheme}\" \
-sim_device \"#{device}\" \
-sim_version \"#{ios_version}\" \
-output \"#{run_output}\""
IO.popen(command) do |fd|
until fd.eof?
puts fd.readline
end
end
puts `
"./Pods/Subliminal/Supporting Files/CI/subliminal_uialog_to_junit" \
-i "#{run_output}/Run\ Data/Automation\ Results.plist" \
-o "#{run_output}/junit.xml"
`
run += 1
end
end
# Create directory listing of this folder
files = []
html = ''
Dir.glob("#{output_path}/*/Run\ Data/*.png") do |file|
unless file.to_s.include?"Expecta Error"
puts "Found screenshot #{file}"
path = file.gsub("#{output_path}/", '')
files << path
image_url = "/screenshots/#{app_id}/ios/#{path}"
html += "<a href='#{image_url}'><img src='#{image_url}'></a> "
end
end
File.write("#{output_path}/files.txt", files)
File.write("#{output_path}/index.html", html)
end
end
task :default => :do_it
task :do_it do |t|
Runner.run
end
@KrauseFx
Copy link
Author

Please use snapshot instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment