scan 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ff87db75cf86a6467b0bc503b542e1f385e249e
4
- data.tar.gz: 2d444cf47a4585bd15225b67edb8791c0860cc2f
3
+ metadata.gz: 9b7020eb2cd9811e364f4918945c656c55aa87f8
4
+ data.tar.gz: 40f0f4a684fe83652412765417da73d3c61510c2
5
5
  SHA512:
6
- metadata.gz: 2cf1e347034fe102a751d3595c75b4093890ffa533831d222c6b064a535cee538f5e4404038ea09ba61a275dcc6e047a13a215a2f3e0bf829867b76817ee4a45
7
- data.tar.gz: fcd6a576314c5907852be1a5c6d709cc83d50e9868f7eb37cc0d14e8b74f4140a41447adb49a951afebb7778a27145cf9499c588a2001e054130d173ede705d0
6
+ metadata.gz: cf86b5d405eb812df5543e6f97b9e39aa0abc130c6b5db0f25aaf6f530c7f89e30467044a1f9cfbbaaaaa89e4d58372b660b20091c860e47b2d9ec924f4195b0
7
+ data.tar.gz: 9c0a526c4cd24fc5a4093ac3216ed0e779284ebb319c637b94460e29c0f4727f85b1f18122dcc747af585c287ee1c694536fc9f64e02185cc4b39b5d1a26e66d
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,41 +1,203 @@
1
- # Scan
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/scan`. To experiment with that code, run `bin/console` for an interactive prompt.
1
+ <h3 align="center">
2
+ <a href="https://github.com/KrauseFx/fastlane">
3
+ <img src="assets/fastlane.png" width="150" />
4
+ <br />
5
+ fastlane
6
+ </a>
7
+ </h3>
8
+ <p align="center">
9
+ <a href="https://github.com/KrauseFx/deliver">deliver</a> &bull;
10
+ <a href="https://github.com/KrauseFx/snapshot">snapshot</a> &bull;
11
+ <a href="https://github.com/KrauseFx/frameit">frameit</a> &bull;
12
+ <a href="https://github.com/KrauseFx/PEM">PEM</a> &bull;
13
+ <a href="https://github.com/KrauseFx/sigh">sigh</a> &bull;
14
+ <a href="https://github.com/KrauseFx/produce">produce</a> &bull;
15
+ <a href="https://github.com/KrauseFx/cert">cert</a> &bull;
16
+ <a href="https://github.com/fastlane/spaceship">spaceship</a> &bull;
17
+ <a href="https://github.com/fastlane/pilot">pilot</a> &bull;
18
+ <a href="https://github.com/fastlane/boarding">boarding</a> &bull;
19
+ <a href="https://github.com/fastlane/gym">gym</a> &bull;
20
+ <b>scan</b>
21
+ </p>
22
+ -------
23
+
24
+ <p align="center">
25
+ <img src="assets/scan.png" height="110">
26
+ </p>
27
+
28
+ scan
29
+ ============
30
+
31
+ [![Twitter: @KauseFx](https://img.shields.io/badge/contact-@KrauseFx-blue.svg?style=flat)](https://twitter.com/KrauseFx)
32
+ [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/fastlane/scan/blob/master/LICENSE)
33
+ [![Gem](https://img.shields.io/gem/v/scan.svg?style=flat)](http://rubygems.org/gems/scan)
34
+ [![Build Status](https://img.shields.io/travis/fastlane/scan/master.svg?style=flat)](https://travis-ci.org/fastlane/scan)
35
+
36
+ ###### Building your app has never been easier
37
+
38
+ Get in contact with the developer on Twitter: [@KrauseFx](https://twitter.com/KrauseFx)
39
+
40
+ -------
41
+ <p align="center">
42
+ <a href="#whats-scan">Features</a> &bull;
43
+ <a href="#installation">Installation</a> &bull;
44
+ <a href="#usage">Usage</a> &bull;
45
+ <a href="#tips">Tips</a> &bull;
46
+ <a href="#need-help">Need help?</a>
47
+ </p>
48
+
49
+ -------
50
+
51
+ <h5 align="center"><code>scan</code> is part of <a href="https://fastlane.tools">fastlane</a>: connect all deployment tools into one streamlined workflow.</h5>
52
+
53
+ # What's scan?
54
+
55
+ `scan` makes it super easy to run tests of your iOS and Mac app. It does all the heavy lifting for you to run your tests... the easy way.
56
+
57
+ ### Before `scan`
58
+
59
+ ```sh
60
+ xcodebuild \
61
+ -workspace MyApp.xcworkspace \
62
+ -scheme "MyApp" \
63
+ -sdk iphonesimulator \
64
+ -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1' \
65
+ test
66
+ ```
4
67
 
5
- TODO: Delete this and the text above, and describe your gem
68
+ As the output will look like this
6
69
 
7
- ## Installation
70
+ ```
71
+ /Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/Objects-normal/arm64/main.o Example/main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
72
+ cd /Users/felixkrause/Developer/fastlane/gym/example/cocoapods
73
+ export LANG=en_US.US-ASCII
74
+ export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/Users/felixkrause/.rvm/gems/ruby-2.2.0/bin:/Users/felixkrause/.rvm/gems/ruby-2.2.0@global/bin:/Users/felixkrause/.rvm/rubies/ruby-2.2.0/bin:/Users/felixkrause/.rvm/bin:/usr/local/heroku/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
75
+ /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch arm64 -fmessage-length=126 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/Users/felixkrause/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/felixkrause/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DCOCOAPODS=1 -DNS_BLOCK_ASSERTIONS=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -miphoneos-version-min=9.0 -g -fvisibility=hidden -Wno-sign-conversion -fembed-bitcode -iquote /Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/ExampleProductName-generated-files.hmap -I/Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/ExampleProductName-own-target-headers.hmap -I/Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/ExampleProductName-all-target-headers.hmap -iquote /Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/ExampleProductName-project-headers.hmap -I/Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/BuildProductsPath/Release-iphoneos/include -I/Users/felixkrause/Developer/fastlane/gym/example/cocoapods/Pods/Headers/Public -I/Users/felixkrause/Developer/fastlane/gym/example/cocoapods/Pods/Headers/Public/HexColors -I/Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/DerivedSources/arm64 -I/Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/DerivedSources -F/Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/BuildProductsPath/Release-iphoneos -isystem /Users/felixkrause/Developer/fastlane/gym/example/cocoapods/Pods/Headers/Public -isystem /Users/felixkrause/Developer/fastlane/gym/example/cocoapods/Pods/Headers/Public/HexColors -MMD -MT dependencies -MF /Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/Objects-normal/arm64/main.d --serialize-diagnostics /Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/Objects-normal/arm64/main.dia -c /Users/felixkrause/Developer/fastlane/gym/example/cocoapods/Example/main.m -o /Users/felixkrause/Library/Developer/Xcode/DerivedData/Example-fhlmxikmujknefgidqwqvtbatohi/Build/Intermediates/ArchiveIntermediates/Example/IntermediateBuildFilesPath/Example.build/Release-iphoneos/Example.build/Objects-normal/arm64/main.o
76
+ ```
77
+ you'll probably want to use something like [xcpretty](https://github.com/supermarin/xcpretty), which will look like this:
78
+
79
+ ```sh
80
+ set -o pipefail &&
81
+ xcodebuild \
82
+ -workspace MyApp.xcworkspace \
83
+ -scheme "MyApp" \
84
+ -sdk iphonesimulator \
85
+ -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1' \
86
+ test \
87
+ | xcpretty \
88
+ -r "html" \
89
+ -o "tests.html"
90
+ ```
8
91
 
9
- Add this line to your application's Gemfile:
92
+ ### With `scan`
10
93
 
11
- ```ruby
12
- gem 'scan'
13
94
  ```
95
+ scan
96
+ ```
97
+
98
+ ### Why `scan`?
99
+
100
+ `scan` uses the latest APIs and tools to make running tests plain simple and offer a great integration into your existing workflow, like [fastlane](https://fastlane.tools) or Jenkins.
101
+
102
+ | scan Features
103
+ --------------------------|------------------------------------------------------------
104
+ :checkered_flag: | Beautiful inline build output while running the tests
105
+ :mountain_cableway: | Sensible defaults: Automatically detect the project, its schemes and more
106
+ :bar_chart: | Support for HTML, JSON and JUnit reports
107
+ :mag: | Xcode duplicated your simulators again? `scan` will handle this for you
108
+ :link: | Works perfectly with [fastlane](https://fastlane.tools) and other tools
109
+ :bullettrain_side: | Don't remember any complicated build commands, just `scan`
110
+ :wrench: | Easy and dynamic configuration using parameters and environment variables
111
+ :loudspeaker: | Beautiful slack notifications of the test results
112
+ :floppy_disk: | Store common build settings in a `Scanfile`
113
+ :outbox_tray: | The raw `xcodebuild` outputs are stored in `~/Library/Logs/scan`
114
+ :computer: | Supports both iOS and Mac applications
115
+ :man: | Automatically switches to the [travis formatter](https://github.com/kattrali/xcpretty-travis-formatter) when running on Travis
116
+ :book: | Helps you resolve common test errors like simulator not responding
117
+
118
+ `scan` uses a plain `xcodebuild` command, therefore keeping 100% compatible with `xcodebuild`. To generate the nice output, `scan` uses [xcpretty](https://github.com/supermarin/xcpretty). You can alway access the raw output in `~/Library/Logs/scan`.
119
+
120
+ ![/assets/scanScreenshot.png](/assets/scanScreenshot.png)
121
+ ![/assets/slack.png](/assets/slack.png)
122
+ ![/assets/scanHTML.png](/assets/scanHTML.png)
123
+ ![/assets/scanHTMLFailing.png](/assets/scanHTMLFailing.png)
124
+
125
+ # Installation
126
+
127
+ sudo gem install scan
128
+
129
+ Make sure, you have the latest version of the Xcode command line tools installed:
130
+
131
+ xcode-select --install
14
132
 
15
- And then execute:
133
+ # Usage
16
134
 
17
- $ bundle
135
+ scan
18
136
 
19
- Or install it yourself as:
137
+ That's all you need to run your tests. If you want more control, here are some available parameters:
20
138
 
21
- $ gem install scan
139
+ scan --workspace "Example.xcworkspace" --scheme "AppName" --clean
22
140
 
23
- ## Usage
141
+ If you need to use a different xcode install, use xcode-select or define DEVELOPER_DIR:
24
142
 
25
- TODO: Write usage instructions here
143
+ DEVELOPER_DIR="/Applications/Xcode6.2.app" scan
26
144
 
27
- ## Development
145
+ For a list of all available parameters use
146
+
147
+ scan --help
148
+
149
+ To access the raw `xcodebuild` output open `~/Library/Logs/scan`
150
+
151
+ # Scanfile
152
+
153
+ Since you might want to manually trigger the tests but don't want to specify all the parameters every time, you can store your defaults in a so called `Scanfile`.
154
+
155
+ Run `scan init` to create a new configuration file. Example:
156
+
157
+ ```ruby
158
+ scheme "Example"
159
+
160
+ clean true
161
+
162
+ output_types "html"
163
+ ```
164
+
165
+ # Automating the whole process
166
+
167
+ `scan` works great together with [fastlane](https://fastlane.tools), which connects all deployment tools into one streamlined workflow.
168
+
169
+ Using `fastlane` you can define a configuration like
170
+
171
+ ```ruby
172
+ lane :test do
173
+ scan(scheme: "Example")
174
+ end
175
+ ```
28
176
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
177
+ For more information visit the [fastlane GitHub page](https://github.com/KrauseFx/fastlane).
30
178
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
179
 
33
- ## Contributing
180
+ # Tips
181
+ ## [`fastlane`](https://fastlane.tools) Toolchain
34
182
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/scan. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
183
+ - [`fastlane`](https://fastlane.tools): Connect all deployment tools into one streamlined workflow
184
+ - [`deliver`](https://github.com/KrauseFx/deliver): Upload screenshots, metadata and your app to the App Store
185
+ - [`snapshot`](https://github.com/KrauseFx/snapshot): Automate taking localized screenshots of your iOS app on every device
186
+ - [`frameit`](https://github.com/KrauseFx/frameit): Quickly put your screenshots into the right device frames
187
+ - [`PEM`](https://github.com/KrauseFx/pem): Automatically generate and renew your push notification profiles
188
+ - [`produce`](https://github.com/KrauseFx/produce): Create new iOS apps on iTunes Connect and Dev Portal using the command line
189
+ - [`cert`](https://github.com/KrauseFx/cert): Automatically create and maintain iOS code signing certificates
190
+ - [`spaceship`](https://github.com/fastlane/spaceship): Ruby library to access the Apple Dev Center and iTunes Connect
191
+ - [`pilot`](https://github.com/fastlane/pilot): The best way to manage your TestFlight testers and builds from your terminal
192
+ - [`boarding`](https://github.com/fastlane/boarding): The easiest way to invite your TestFlight beta testers
193
+ - [`gym`](https://github.com/fastlane/gym): Building your iOS apps has never been easier
36
194
 
195
+ ##### [Like this tool? Be the first to know about updates and new fastlane tools](https://tinyletter.com/krausefx)
37
196
 
38
- ## License
197
+ # Need help?
198
+ Please submit an issue on GitHub and provide information about your setup
39
199
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
200
+ # License
201
+ This project is licensed under the terms of the MIT license. See the LICENSE file.
41
202
 
203
+ > This project and all fastlane tools are in no way affiliated with Apple Inc. This project is open source under the MIT license, which means you have full access to the source code and can modify it to fit your own needs. All fastlane tools run on your own computer or server, so your credentials or other sensitive information will never leave your own computer. You are responsible for how you use fastlane tools.
data/bin/scan ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.push File.expand_path("../../lib", __FILE__)
3
+
4
+ require "scan"
5
+ require "scan/commands_generator"
6
+ Scan::CommandsGenerator.start
@@ -0,0 +1,13 @@
1
+ # For more information about this configuation visit
2
+ # https://github.com/fastlane/scan#scanfile
3
+
4
+ # In general, you can use the options available
5
+ # scan --help
6
+
7
+ # Remove the # in front of the line to enable the option
8
+
9
+ # scheme "Example"
10
+
11
+ # skip_html_open true
12
+
13
+ # clean true
data/lib/scan.rb CHANGED
@@ -1,5 +1,35 @@
1
- require "scan/version"
1
+ require 'json'
2
+ require 'scan/version'
3
+ require 'scan/manager'
4
+ require 'scan/options'
5
+ require 'scan/runner'
6
+ require 'scan/detect_values'
7
+ require 'scan/report_collector'
8
+ require 'scan/test_command_generator'
9
+ require 'scan/test_result_parser'
10
+ require 'scan/error_handler'
11
+ require 'scan/slack_poster'
12
+
13
+ require 'fastlane_core'
2
14
 
3
15
  module Scan
4
- # Your code goes here...
16
+ class << self
17
+ attr_accessor :config
18
+
19
+ attr_accessor :project
20
+
21
+ attr_accessor :cache
22
+
23
+ def config=(value)
24
+ @config = value
25
+ DetectValues.set_additional_default_values
26
+ @cache = {}
27
+ end
28
+
29
+ def scanfile_name
30
+ "Scanfile"
31
+ end
32
+ end
33
+
34
+ Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore
5
35
  end
@@ -0,0 +1,63 @@
1
+ require "commander"
2
+ require "fastlane_core"
3
+
4
+ HighLine.track_eof = false
5
+
6
+ module Scan
7
+ class CommandsGenerator
8
+ include Commander::Methods
9
+
10
+ FastlaneCore::CommanderGenerator.new.generate(Scan::Options.available_options)
11
+
12
+ def self.start
13
+ FastlaneCore::UpdateChecker.start_looking_for_update("scan")
14
+ new.run
15
+ ensure
16
+ FastlaneCore::UpdateChecker.show_update_status("scan", Scan::VERSION)
17
+ end
18
+
19
+ def convert_options(options)
20
+ o = options.__hash__.dup
21
+ o.delete(:verbose)
22
+ o
23
+ end
24
+
25
+ def run
26
+ program :version, Scan::VERSION
27
+ program :description, Scan::DESCRIPTION
28
+ program :help, "Author", "Felix Krause <scan@krausefx.com>"
29
+ program :help, "Website", "https://fastlane.tools"
30
+ program :help, "GitHub", "https://github.com/fastlane/scan"
31
+ program :help_formatter, :compact
32
+
33
+ global_option("--verbose") { $verbose = true }
34
+
35
+ command :tests do |c|
36
+ c.syntax = "scan"
37
+ c.description = Scan::DESCRIPTION
38
+ c.action do |_args, options|
39
+ config = FastlaneCore::Configuration.create(Scan::Options.available_options,
40
+ convert_options(options))
41
+ Scan::Manager.new.work(config)
42
+ end
43
+ end
44
+
45
+ command :init do |c|
46
+ c.syntax = "scan init"
47
+ c.description = "Creates a new Scanfile for you"
48
+ c.action do |_args, options|
49
+ containing = (Helper.fastlane_enabled? ? 'fastlane' : '.')
50
+ path = File.join(containing, Scan.scanfile_name)
51
+ raise "Scanfile already exists".yellow if File.exist?(path)
52
+ template = File.read("#{Helper.gem_path('scan')}/lib/assets/ScanfileTemplate")
53
+ File.write(path, template)
54
+ Helper.log.info "Successfully created '#{path}'. Open the file using a code editor.".green
55
+ end
56
+ end
57
+
58
+ default_command :tests
59
+
60
+ run!
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,59 @@
1
+ module Scan
2
+ # This class detects all kinds of default values
3
+ class DetectValues
4
+ # This is needed as these are more complex default values
5
+ # Returns the finished config object
6
+ def self.set_additional_default_values
7
+ config = Scan.config
8
+
9
+ FastlaneCore::Project.detect_projects(config)
10
+ Scan.project = FastlaneCore::Project.new(config)
11
+
12
+ # Go into the project's folder
13
+ Dir.chdir(File.expand_path("..", Scan.project.path)) do
14
+ config.load_configuration_file(Scan.scanfile_name)
15
+ end
16
+
17
+ Scan.project.select_scheme
18
+
19
+ default_device if Scan.project.ios?
20
+ detect_destination
21
+
22
+ return config
23
+ end
24
+
25
+ def self.default_device
26
+ config = Scan.config
27
+
28
+ if config[:device] # make sure it actually exists
29
+ return if FastlaneCore::Simulator.all.find { |d| d.name == config[:device].strip }
30
+ Helper.log.error "Couldn't find simulator '#{config[:device]}' - falling back to default simulator".red
31
+ end
32
+
33
+ # An iPhone 5s is reasonable small and useful for tests
34
+ found = FastlaneCore::Simulator.all.find { |d| d.name == "iPhone 5s" }
35
+ found ||= FastlaneCore::Simulator.all.first # anything is better than nothing
36
+
37
+ config[:device] = found
38
+ raise "No simulators found".red unless config[:device]
39
+ end
40
+
41
+ # Is it an iOS device or a Mac?
42
+ def self.detect_destination
43
+ if Scan.config[:destination]
44
+ Helper.log.info "It's not recommended to set the `destination` value directly".yellow
45
+ Helper.log.info "Instead use the other options available in `scan --help`".yellow
46
+ Helper.log.info "Using your value '#{Scan.config[:destination]}' for now".yellow
47
+ Helper.log.info "because I trust you know what you're doing...".yellow
48
+ return
49
+ end
50
+
51
+ # building up the destination now
52
+ if Scan.project.ios?
53
+ Scan.config[:destination] = "platform=iOS Simulator,id=#{Scan.config[:device].udid}"
54
+ else
55
+ Scan.config[:destination] = "platform=OS X"
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,43 @@
1
+ module Scan
2
+ # This classes methods are called when something goes wrong in the building process
3
+ class ErrorHandler
4
+ class << self
5
+ # @param [String] The output of the errored build
6
+ # This method should raise an exception in any case, as the return code indicated a failed build
7
+ def handle_build_error(output)
8
+ # The order of the handling below is import
9
+ case output
10
+ when /US\-ASCII/
11
+ print "Your shell environment is not correctly configured"
12
+ print "Instead of UTF-8 your shell uses US-ASCII"
13
+ print "Please add the following to your '~/.bashrc':"
14
+ print ""
15
+ print " export LANG=en_US.UTF-8"
16
+ print " export LANGUAGE=en_US.UTF-8"
17
+ print " export LC_ALL=en_US.UTF-8"
18
+ print ""
19
+ print "You'll have to restart your shell session after updating the file."
20
+ print "If you are using zshell or another shell, make sure to edit the correct bash file."
21
+ print "For more information visit this stackoverflow answer:"
22
+ print "https://stackoverflow.com/a/17031697/445598"
23
+ when /Testing failed/
24
+ raise "Error building the application - see the log above".red
25
+ when /Executed/
26
+ # this is *really* important:
27
+ # we don't want to raise an exception here
28
+ # as we handle this in runner.rb at a later point
29
+ # after parsing the actual test results
30
+ return
31
+ end
32
+ raise "Error building/testing the application - see the log above".red
33
+ end
34
+
35
+ private
36
+
37
+ # Just to make things easier
38
+ def print(text)
39
+ Helper.log.error text.red
40
+ end
41
+ end
42
+ end
43
+ end