xctester 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8941acfc088d13ca7bdaf28ee0fa777b2de1ac2a
4
+ data.tar.gz: 1df4e194880c7bca74b18e1932defb2acd519810
5
+ SHA512:
6
+ metadata.gz: 5e0d9b47c76f96f28b3b828a65be77a941eb0ac937eac82744280890c7fe0c40f3acc7a208d9b456bff24b770ee176fbc6b63ce351fc9de875772cb31ffd80b5
7
+ data.tar.gz: 927478105e65c9b4b5c06e582c4f42cd8f08c24d5791e83446f4594c29cbbf3ec65bb11a180c7327b6dbc719358cb774322b06151aa09633fb880f345b8fea5d
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in xctester.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Xctester
2
+
3
+ Xctester is a basic script that run Xcode tests and generate log files for each run.
4
+
5
+ ## Installation
6
+
7
+
8
+ Simply install it as:
9
+
10
+ $ gem install xctester
11
+
12
+ ## Usage
13
+
14
+ ```
15
+ ./xctester -h
16
+ Usage: ./xctester [options]
17
+ -v, --[no-]verbose Run verbosely
18
+ -t, --tests test Specify how many time you want to run your unit tests
19
+ -s, --scheme scheme The scheme to execute
20
+ -p, --project project The project file (xcodeproj) or workspace file (xcworkspace) to test
21
+ -o, --timeout timeout The maximun time (in seconds) allowed to launch the test
22
+ ```
23
+
24
+ ## Contributing
25
+
26
+ Bug reports and pull requests are welcome at https://github.com/nonouf/xctester.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "xctester"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/xctester ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'xctester'
4
+
5
+ xctester = Xctester::Tester.new
6
+ xctester.run
@@ -0,0 +1,3 @@
1
+ module Xctester
2
+ VERSION = "0.1.0"
3
+ end
data/lib/xctester.rb ADDED
@@ -0,0 +1,101 @@
1
+ require "xctester/version"
2
+ require "optparse"
3
+ require "POpen4"
4
+ require "FileUtils"
5
+ require "colorize"
6
+ require "timeout"
7
+ require "benchmark"
8
+
9
+ module Xctester
10
+ class Tester
11
+ def run
12
+ $options = {:tests => 1, :verbose => false, :timeout => 300}
13
+ $dir_name = "test_results"
14
+ $file_prefix = "test_"
15
+ $failed = 0
16
+
17
+ OptionParser.new do |opts|
18
+ opts.banner = "Usage: ./xctester [options]"
19
+
20
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
21
+ $options[:verbose] = v
22
+ end
23
+ opts.on("-t", "--tests test", "Specify how many time you want to run your unit tests") do |t|
24
+ $options[:tests] = t.to_i
25
+ end
26
+ opts.on("-s", "--scheme scheme", "The scheme to execute") do |s|
27
+ $options[:scheme] = s
28
+ end
29
+ opts.on("-p", "--project project", "The project file (xcodeproj) or workspace file (xcworkspace) to test") do |p|
30
+ $options[:project] = p
31
+ end
32
+ opts.on("-o", "--timeout timeout", "The maximun time (in seconds) allowed to launch the test") do |o|
33
+ $options[:timeout] = o
34
+ end
35
+ end.parse!
36
+
37
+ def run_test(i)
38
+ status = -1
39
+
40
+ time = Benchmark.measure {
41
+ proj = (File.extname($options[:project]) == ".xcworkspace")? "-workspace" : "-project"
42
+ cmd = "xcodebuild #{proj} #{$options[:project]} -scheme '#{$options[:scheme]}' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' test"
43
+ output = ""
44
+
45
+ status = POpen4::popen4(cmd) do |stdout, stderr, stdin, pid|
46
+ puts " (#{pid})".green
47
+
48
+ while out = stdout.gets || err = stderr.gets do
49
+ if out
50
+ if $options[:verbose]
51
+ puts "#{out}"
52
+ end
53
+ output += out
54
+ end
55
+
56
+ if err
57
+ puts "#{err}".red
58
+ output += err
59
+ end
60
+
61
+ end
62
+ end
63
+
64
+ if status.exitstatus > 0
65
+ path = "#{Dir.pwd}/#{$dir_name}"
66
+ filename = "#{$file_prefix}#{i}.log"
67
+ fullpath = "#{path}/#{filename}"
68
+
69
+ puts "The logs can be found here -> #{fullpath}".yellow
70
+ Dir.mkdir(path) unless File.exists?($dir_name)
71
+ File.write(fullpath, output)
72
+ $failed += 1
73
+ end
74
+ }
75
+ puts "\nFinish running test #{i} with exit status #{status.exitstatus} (#{time.real}s)\n".green
76
+ end
77
+
78
+ i = 0
79
+
80
+ if File.exists?($dir_name)
81
+ puts "Delete logs' folders at #{$dir_name}"
82
+ FileUtils.rm_rf($dir_name)
83
+ end
84
+
85
+ while i < $options[:tests] do
86
+ print "Running test #{i + 1}...".green
87
+
88
+ begin
89
+ Timeout::timeout($options[:timeout]) do
90
+ run_test(i + 1)
91
+ end
92
+ rescue Timeout::Error
93
+ puts "Test #{i + 1} timed out and has been stopped.".yellow
94
+ end
95
+ i += 1
96
+ end
97
+
98
+ puts "#{$options[:tests] - $failed}/#{$options[:tests]} passed."
99
+ end
100
+ end
101
+ end
data/xctester.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'xctester/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "xctester"
8
+ spec.version = Xctester::VERSION
9
+ spec.authors = ["Arnaud Schildknecht"]
10
+ spec.email = ["arnaud.schild@gmail.com"]
11
+
12
+ spec.summary = %q{A basic script that run Xcode tests.}
13
+ spec.homepage = "https://github.com/Nonouf/xctester"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "bin"
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "OptionParser", "~> 0.5"
21
+ spec.add_dependency "POpen4", "~> 0.1"
22
+ spec.add_dependency "colorize", "~> 0.7"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.11"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xctester
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Arnaud Schildknecht
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: OptionParser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: POpen4
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.11'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.11'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description:
84
+ email:
85
+ - arnaud.schild@gmail.com
86
+ executables:
87
+ - console
88
+ - setup
89
+ - xctester
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - Gemfile
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - bin/xctester
100
+ - lib/xctester.rb
101
+ - lib/xctester/version.rb
102
+ - xctester.gemspec
103
+ homepage: https://github.com/Nonouf/xctester
104
+ licenses: []
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.5.0
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: A basic script that run Xcode tests.
126
+ test_files: []