snapshot 0.4.13 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -16
- data/bin/snapshot +2 -1
- data/lib/assets/SnapfileTemplate +4 -12
- data/lib/snapshot/dependency_checker.rb +2 -2
- data/lib/snapshot/latest_ios_version.rb +11 -1
- data/lib/snapshot/reports_generator.rb +3 -1
- data/lib/snapshot/reset_simulators.rb +9 -5
- data/lib/snapshot/runner.rb +36 -16
- data/lib/snapshot/snapfile_creator.rb +3 -3
- data/lib/snapshot/snapshot_config.rb +2 -1
- data/lib/snapshot/snapshot_file.rb +1 -0
- data/lib/snapshot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54a6a5e5c88121d5cd4642db73d3d91abda68652
|
4
|
+
data.tar.gz: eb8ccdeacbc9fe7e28eba1303ae893bfd7aa5b15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc159b6a65bc09699e93ce6d6e2c07fd0e9f27a226475731c5baa9f42b77488046bc9216ad47447a2fb0e9f8916b8890475d07e7429e820df3ceeda15c72e262
|
7
|
+
data.tar.gz: 7cf3a8180e30074137ce70c01bcbe022cd5513eabce15a1cd9711206b51b147de2025244bc7b84f0924beb5f916fdfa701097b53a27e6b1e995f9497578b2047
|
data/README.md
CHANGED
@@ -259,24 +259,13 @@ This can be used to
|
|
259
259
|
|
260
260
|
To run a shell script, just use ```system('./script.sh')```.
|
261
261
|
```ruby
|
262
|
-
setup_for_device_change do |device, udid|
|
263
|
-
puts "
|
264
|
-
|
265
|
-
# Completely reset the device before we start taking screenshots
|
266
|
-
system("xcrun simctl erase #{udid}")
|
267
|
-
end
|
268
|
-
|
269
|
-
setup_for_language_change do |lang, device|
|
270
|
-
puts "Running #{lang} on #{device}"
|
271
|
-
system("./populateDatabase.sh")
|
272
|
-
end
|
273
|
-
|
274
|
-
teardown_language do |lang, device|
|
275
|
-
puts "Finished with #{lang} on #{device}"
|
262
|
+
setup_for_device_change do |device, udid, language|
|
263
|
+
puts "Running #{language} on #{device}"
|
264
|
+
system("./popuplateDatabase.sh")
|
276
265
|
end
|
277
266
|
|
278
|
-
teardown_device do |device|
|
279
|
-
puts "
|
267
|
+
teardown_device do |language, device|
|
268
|
+
puts "Finished with #{language} on #{device}"
|
280
269
|
system("./cleanup.sh")
|
281
270
|
end
|
282
271
|
```
|
data/bin/snapshot
CHANGED
@@ -34,6 +34,7 @@ class SnapshotApplication
|
|
34
34
|
c.action do |args, options|
|
35
35
|
path = (Snapshot::Helper.fastlane_enabled?? './fastlane' : '.')
|
36
36
|
Dir.chdir(path) do # switch the context
|
37
|
+
Snapshot::DependencyChecker.check_simulators
|
37
38
|
Snapshot::SnapshotConfig.shared_instance(options.snapfile)
|
38
39
|
Snapshot::Runner.new.work(clean: !options.noclean)
|
39
40
|
end
|
@@ -56,7 +57,7 @@ class SnapshotApplication
|
|
56
57
|
c.option '-i', '--ios String', String, 'The iOS Version you want to use'
|
57
58
|
|
58
59
|
c.action do |args, options|
|
59
|
-
version = options.ios ||
|
60
|
+
version = options.ios || Snapshot::LatestIosVersion.version
|
60
61
|
require 'snapshot/reset_simulators'
|
61
62
|
|
62
63
|
Snapshot::ResetSimulators.clear_everything!(version)
|
data/lib/assets/SnapfileTemplate
CHANGED
@@ -34,20 +34,12 @@ screenshots_path "./screenshots"
|
|
34
34
|
|
35
35
|
# Custom Callbacks
|
36
36
|
|
37
|
-
# setup_for_device_change do |device|
|
38
|
-
# puts "
|
39
|
-
# end
|
40
|
-
|
41
|
-
# setup_for_language_change do |lang, device|
|
42
|
-
# puts "Running #{lang} on #{device}"
|
37
|
+
# setup_for_device_change do |device, udid, language|
|
38
|
+
# puts "Running #{language} on #{device}"
|
43
39
|
# system("./popuplateDatabase.sh")
|
44
40
|
# end
|
45
41
|
|
46
|
-
#
|
47
|
-
# puts "Finished with #{
|
48
|
-
# end
|
49
|
-
|
50
|
-
# teardown_device do |device|
|
51
|
-
# puts "Cleaning device #{device}"
|
42
|
+
# teardown_device do |language, device|
|
43
|
+
# puts "Finished with #{language} on #{device}"
|
52
44
|
# system("./cleanup.sh")
|
53
45
|
# end
|
@@ -2,7 +2,6 @@ module Snapshot
|
|
2
2
|
class DependencyChecker
|
3
3
|
def self.check_dependencies
|
4
4
|
self.check_xcode_select
|
5
|
-
self.check_simulators
|
6
5
|
self.check_xctool
|
7
6
|
self.check_for_automation_subfolder
|
8
7
|
self.check_simctl
|
@@ -24,7 +23,8 @@ module Snapshot
|
|
24
23
|
if Simulators.available_devices.count < 1
|
25
24
|
Helper.log.fatal '#############################################################'
|
26
25
|
Helper.log.fatal "# You have to add new simulators using Xcode"
|
27
|
-
Helper.log.fatal "#
|
26
|
+
Helper.log.fatal "# You can let snapshot create new simulators: 'snapshot reset_simulators'"
|
27
|
+
Helper.log.fatal "# Manually: Xcode => Window => Devices"
|
28
28
|
Helper.log.fatal "# Please run `instruments -s` to verify your xcode path"
|
29
29
|
Helper.log.fatal '#############################################################'
|
30
30
|
raise "Create the new simulators and run this script again"
|
@@ -1,5 +1,15 @@
|
|
1
1
|
module Snapshot
|
2
2
|
class LatestIosVersion
|
3
|
-
|
3
|
+
def self.version
|
4
|
+
return ENV["SNAPSHOT_IOS_VERSION"] if ENV["SNAPSHOT_IOS_VERSION"]
|
5
|
+
|
6
|
+
output = `xcodebuild -version -sdk`.split("Mac").last # don't care about the Mac Part
|
7
|
+
matched = output.match(/SDKVersion: ([\d\.]+)/)
|
8
|
+
if matched.length > 1
|
9
|
+
return matched[1]
|
10
|
+
else
|
11
|
+
raise "Could not determine installed iOS SDK version. Please pass it via the environment variable 'SNAPSHOT_IOS_VERSION'".red
|
12
|
+
end
|
13
|
+
end
|
4
14
|
end
|
5
15
|
end
|
@@ -33,7 +33,9 @@ module Snapshot
|
|
33
33
|
export_path = "#{screens_path}/screenshots.html"
|
34
34
|
File.write(export_path, html)
|
35
35
|
|
36
|
-
|
36
|
+
export_path = File.expand_path(export_path)
|
37
|
+
Helper.log.info "Successfully created HTML file with an overview of all the screenshots: '#{export_path}'".green
|
38
|
+
system("open '#{export_path}'") unless ENV["SNAPSHOT_SKIP_OPEN_SUMMARY"]
|
37
39
|
end
|
38
40
|
|
39
41
|
private
|
@@ -15,12 +15,16 @@ module Snapshot
|
|
15
15
|
device_types_output = `xcrun simctl list devicetypes`
|
16
16
|
device_types = device_types_output.scan /(.*) \((.*)\)/
|
17
17
|
|
18
|
-
devices_output = `xcrun simctl list devices
|
19
|
-
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/
|
18
|
+
devices_output = `xcrun simctl list devices`.split("\n")
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
devices_output.each do |line|
|
21
|
+
device = line.match(/\s+([\w\s]+)\(([\w\-]+)\)/)
|
22
|
+
if device and device.length == 3
|
23
|
+
name = device[1].strip
|
24
|
+
id = device[2]
|
25
|
+
puts "Removing device #{name} (#{id})"
|
26
|
+
`xcrun simctl delete #{id}`
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
device_types.each do |device_type|
|
data/lib/snapshot/runner.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pty'
|
2
|
+
require 'shellwords'
|
2
3
|
|
3
4
|
module Snapshot
|
4
5
|
class Runner
|
@@ -8,7 +9,7 @@ module Snapshot
|
|
8
9
|
SnapshotConfig.shared_instance.js_file # to verify the file can be found earlier
|
9
10
|
|
10
11
|
Builder.new.build_app(clean: clean)
|
11
|
-
@app_path =
|
12
|
+
@app_path = determine_app_path
|
12
13
|
|
13
14
|
counter = 0
|
14
15
|
errors = []
|
@@ -16,22 +17,20 @@ module Snapshot
|
|
16
17
|
FileUtils.rm_rf SnapshotConfig.shared_instance.screenshots_path if SnapshotConfig.shared_instance.clear_previous_screenshots
|
17
18
|
|
18
19
|
SnapshotConfig.shared_instance.devices.each do |device|
|
19
|
-
|
20
|
-
SnapshotConfig.shared_instance.blocks[:setup_for_device_change].call(device, udid_for_simulator(device)) # Callback
|
21
|
-
|
22
20
|
SnapshotConfig.shared_instance.languages.each do |language|
|
23
|
-
SnapshotConfig.shared_instance.blocks[:setup_for_language_change].call(language, device) # Callback
|
24
|
-
|
25
21
|
reinstall_app(device, language) unless ENV["SNAPSHOT_SKIP_UNINSTALL"]
|
22
|
+
|
23
|
+
prepare_simulator(device, language)
|
24
|
+
|
26
25
|
begin
|
27
26
|
errors.concat(run_tests(device, language))
|
28
27
|
counter += copy_screenshots(language)
|
29
28
|
rescue => ex
|
30
29
|
Helper.log.error(ex)
|
31
30
|
end
|
32
|
-
|
31
|
+
|
32
|
+
teardown_simulator(device, language)
|
33
33
|
end
|
34
|
-
SnapshotConfig.shared_instance.blocks[:teardown_device].call(device) # Callback
|
35
34
|
end
|
36
35
|
|
37
36
|
`killall "iOS Simulator"` # close the simulator after the script is finished
|
@@ -55,6 +54,16 @@ module Snapshot
|
|
55
54
|
FileUtils.mkdir_p(TRACE_DIR)
|
56
55
|
end
|
57
56
|
|
57
|
+
def prepare_simulator(device, language)
|
58
|
+
SnapshotConfig.shared_instance.blocks[:setup_for_device_change].call(device, udid_for_simulator(device), language) # Callback
|
59
|
+
SnapshotConfig.shared_instance.blocks[:setup_for_language_change].call(language, device) # deprecated
|
60
|
+
end
|
61
|
+
|
62
|
+
def teardown_simulator(device, language)
|
63
|
+
SnapshotConfig.shared_instance.blocks[:teardown_language].call(language, device) # Callback
|
64
|
+
SnapshotConfig.shared_instance.blocks[:teardown_device].call(device, language) # deprecated
|
65
|
+
end
|
66
|
+
|
58
67
|
def udid_for_simulator(name) # fetches the UDID of the simulator type
|
59
68
|
all = `instruments -s`.split("\n")
|
60
69
|
all.each do |current|
|
@@ -65,12 +74,8 @@ module Snapshot
|
|
65
74
|
|
66
75
|
def reinstall_app(device, language)
|
67
76
|
|
68
|
-
|
69
|
-
|
70
|
-
@app_identifier ||= `/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /tmp/snapshot/build/*.app/Info.plist`
|
71
|
-
@app_identifier ||= `/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /tmp/snapshot/build/*.app/*.plist`
|
72
|
-
@app_identifier.strip
|
73
|
-
end
|
77
|
+
app_identifier = ENV["SNAPSHOT_APP_IDENTIFIER"]
|
78
|
+
app_identifier ||= @app_identifier
|
74
79
|
|
75
80
|
def com(cmd)
|
76
81
|
puts cmd.magenta
|
@@ -86,7 +91,7 @@ module Snapshot
|
|
86
91
|
com("xcrun simctl boot '#{udid}'")
|
87
92
|
com("xcrun simctl uninstall booted '#{app_identifier}'")
|
88
93
|
sleep 3
|
89
|
-
com("xcrun simctl install booted '#{@app_path}'")
|
94
|
+
com("xcrun simctl install booted '#{@app_path.shellescape}'")
|
90
95
|
com("xcrun simctl shutdown booted")
|
91
96
|
end
|
92
97
|
|
@@ -146,6 +151,21 @@ module Snapshot
|
|
146
151
|
return errors
|
147
152
|
end
|
148
153
|
|
154
|
+
def determine_app_path
|
155
|
+
# Determine the path to the actual app and not the WatchKit app
|
156
|
+
Dir.glob("/tmp/snapshot/build/*.app/*.plist").each do |path|
|
157
|
+
watchkit_enabled = `/usr/libexec/PlistBuddy -c 'Print WKWatchKitApp' '#{path}'`.strip
|
158
|
+
next if watchkit_enabled == 'true' # we don't care about WatchKit Apps
|
159
|
+
|
160
|
+
app_identifier = `/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' '#{path}'`.strip
|
161
|
+
if app_identifier and app_identifier.length > 0
|
162
|
+
# This seems to be the valid Info.plist
|
163
|
+
@app_identifier = app_identifier
|
164
|
+
return File.expand_path("..", path) # the app
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
149
169
|
def parse_test_line(line)
|
150
170
|
if line =~ /.*Target failed to run.*/
|
151
171
|
return :retry
|
@@ -188,7 +208,7 @@ module Snapshot
|
|
188
208
|
"-w '#{device}'",
|
189
209
|
"-D '#{TRACE_DIR}/trace'",
|
190
210
|
"-t 'Automation'",
|
191
|
-
"
|
211
|
+
"#{@app_path.shellescape}",
|
192
212
|
"-e UIARESULTSPATH '#{TRACE_DIR}'",
|
193
213
|
"-e UIASCRIPT '#{script_path}'",
|
194
214
|
"-AppleLanguages '(#{language})'",
|
@@ -12,9 +12,9 @@ module Snapshot
|
|
12
12
|
File.write([path, 'snapshot-iPad.js'].join('/'), File.read("#{gem_path}/lib/assets/snapshot.js"))
|
13
13
|
File.write([path, 'SnapshotHelper.js'].join('/'), File.read("#{gem_path}/lib/assets/SnapshotHelper.js"))
|
14
14
|
|
15
|
-
puts "Successfully created SnapshotHelper.js '#{
|
16
|
-
puts "Successfully created new UI Automation JS file at '#{
|
17
|
-
puts "Successfully created new UI Automation JS file for iPad at '#{
|
15
|
+
puts "Successfully created SnapshotHelper.js '#{File.join(path, 'SnapshotHelper.js')}'".green
|
16
|
+
puts "Successfully created new UI Automation JS file at '#{File.join(path, 'snapshot.js')}'".green
|
17
|
+
puts "Successfully created new UI Automation JS file for iPad at '#{File.join(path, 'snapshot-iPad.js')}'".green
|
18
18
|
puts "Successfully created new Snapfile at '#{snapfile_path}'".green
|
19
19
|
end
|
20
20
|
end
|
@@ -51,6 +51,7 @@ module Snapshot
|
|
51
51
|
|
52
52
|
# @param path (String) the path to the config file to use (including the file name)
|
53
53
|
def initialize(path = nil)
|
54
|
+
DependencyChecker.check_simulators
|
54
55
|
path ||= './Snapfile'
|
55
56
|
set_defaults
|
56
57
|
|
@@ -73,7 +74,7 @@ module Snapshot
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def set_defaults
|
76
|
-
self.ios_version = Snapshot::LatestIosVersion
|
77
|
+
self.ios_version = Snapshot::LatestIosVersion.version
|
77
78
|
|
78
79
|
self.languages = [
|
79
80
|
'de-DE',
|
@@ -68,6 +68,7 @@ module Snapshot
|
|
68
68
|
# Blocks
|
69
69
|
when :setup_for_device_change, :teardown_device, :setup_for_language_change, :teardown_language
|
70
70
|
raise "#{method_sym} needs to have a block provided." unless block_given?
|
71
|
+
Helper.log.warn("'setup_for_language_change' and 'teardown_language' are deprecated.".yellow) if [:setup_for_language_change, :teardown_language].include?method_sym
|
71
72
|
@config.blocks[method_sym] = block
|
72
73
|
else
|
73
74
|
Helper.log.error "Unknown method #{method_sym}"
|
data/lib/snapshot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastimage
|