guardian-angel 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ga_runner.rb +3 -14
- data/lib/guardian_angel.rb +2 -1
- data/lib/xcodebuild_runner.rb +89 -0
- data/lib/xctool_runner.rb +10 -0
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c3d7a4126ea074120b6b45eefd6e1318a88c441
|
4
|
+
data.tar.gz: 3ccfdf46e4bd7310da9a2c4d83d0cf55d84425a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed8f3b0d935e3e7f974a5e2e0a2f282ab2c1afe8b71cc4149784c36c81b3689bd2e4494a47f443abb9f3bd4b252a8d0fc682c5de0ad1d24497c570070ff7ddcd
|
7
|
+
data.tar.gz: 3393584c81d0e82d6448febe7b9d8117aaf8aecc16a5d58a1174d95022cebd4ac944e45f20bcadac7f5f6824e428ed0d6a7524cd49d8c37e0cc087712aee4795
|
data/lib/ga_runner.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'ga_logger'
|
2
2
|
require 'guardian_angel'
|
3
3
|
require 'xctool_runner'
|
4
|
+
require 'xcodebuild_runner'
|
4
5
|
|
5
6
|
# @author Vittorio Monaco
|
6
7
|
class GARunner
|
@@ -12,7 +13,7 @@ class GARunner
|
|
12
13
|
def initialize(configuration, filename)
|
13
14
|
@configuration=configuration
|
14
15
|
@filename=filename
|
15
|
-
@runner=
|
16
|
+
@runner=XcodebuildRunner.new(configuration)
|
16
17
|
end
|
17
18
|
|
18
19
|
# Runs unit tests for the given filename, if a tests file exists
|
@@ -34,11 +35,9 @@ class GARunner
|
|
34
35
|
|
35
36
|
# Tries to run unit tests for the filename setup during initialization
|
36
37
|
#
|
37
|
-
# @note if the filename is a tests file, this method strips the tests suffix and runs the tests for the right file instead, after having built the tests project first
|
38
|
-
# (see #buildIfNeeded)
|
39
38
|
# (see #testIfAvailable)
|
40
39
|
def test()
|
41
|
-
|
40
|
+
@runner.prepareForFile(@filename)
|
42
41
|
testIfAvailable(codeFilename())
|
43
42
|
end
|
44
43
|
|
@@ -57,14 +56,4 @@ class GARunner
|
|
57
56
|
|
58
57
|
return stripped
|
59
58
|
end
|
60
|
-
|
61
|
-
# This method builds the tests project if the filename setup during initialization is a tests file
|
62
|
-
# (see #isTest)
|
63
|
-
def buildIfNeeded()
|
64
|
-
if isTest()
|
65
|
-
GALogger.log(@filename + ' is a test, building all the tests...')
|
66
|
-
end
|
67
|
-
|
68
|
-
GuardianAngel.buildWithConfiguration(@configuration)
|
69
|
-
end
|
70
59
|
end
|
data/lib/guardian_angel.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'ga_logger'
|
2
2
|
require 'xctool_runner'
|
3
|
+
require 'xcodebuild_runner'
|
3
4
|
|
4
5
|
# @author Vittorio Monaco
|
5
6
|
class GuardianAngel
|
@@ -8,7 +9,7 @@ class GuardianAngel
|
|
8
9
|
# @param configuration [GAConfiguration] the configuration you want to use to run the tests (see #GAConfiguration)
|
9
10
|
def initialize(configuration)
|
10
11
|
@configuration=configuration
|
11
|
-
@runner=
|
12
|
+
@runner=XcodebuildRunner.new(configuration)
|
12
13
|
end
|
13
14
|
|
14
15
|
# Convenience method to build tests in a stand-alone fashion
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'ga_logger'
|
2
|
+
|
3
|
+
# @author Vittorio Monaco
|
4
|
+
class XcodebuildRunner
|
5
|
+
# Creates a new instance given a GAConfiguration object
|
6
|
+
#
|
7
|
+
# @param configuration [GAConfiguration] the configuration you want to use to build and run the tests (see #GAConfiguration)
|
8
|
+
def initialize(configuration)
|
9
|
+
@configuration=configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
# Tells the runner to prepare the environment for a subsequent test run
|
13
|
+
#
|
14
|
+
# @param filename [String] the name of the file the caller wishes to test
|
15
|
+
#
|
16
|
+
# @note since xcodebuild doesn't offer a way to test single files, this method doesn't do anything
|
17
|
+
# (see #build)
|
18
|
+
def prepareForFile(filename)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Builds (and runs) the tests target through xcodebuild
|
22
|
+
#
|
23
|
+
# @note This method supports both workspace- and project-based environments
|
24
|
+
def build()
|
25
|
+
workspace = @configuration.workspace
|
26
|
+
scheme = @configuration.scheme
|
27
|
+
target = @configuration.target
|
28
|
+
project = @configuration.project
|
29
|
+
xctool = @configuration.xctool_path
|
30
|
+
|
31
|
+
building = workspace
|
32
|
+
building = project if workspace.nil?
|
33
|
+
|
34
|
+
GALogger.log("Building " + building + " with scheme " + scheme + "...")
|
35
|
+
|
36
|
+
toBuild = buildArgument()
|
37
|
+
buildSucceeded = system("xcodebuild" + toBuild +
|
38
|
+
' -scheme ' + scheme +
|
39
|
+
' -sdk iphonesimulator' +
|
40
|
+
' test | xcpretty -tc', out: $stdout, err: :out)
|
41
|
+
|
42
|
+
if buildSucceeded
|
43
|
+
GALogger.log('Tests are fine. Start coding :)', :Success)
|
44
|
+
else
|
45
|
+
GALogger.log('Tests failed. Fix them before you start iterating.', :Error)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the main argument for xctool to build the project/workspace
|
50
|
+
#
|
51
|
+
# Example:
|
52
|
+
# -workspace 'MyWorkspace.xcworkspace'
|
53
|
+
# or
|
54
|
+
# -project 'MyProject.xcodeproj'
|
55
|
+
def buildArgument()
|
56
|
+
workspace = @configuration.workspace
|
57
|
+
scheme = @configuration.scheme
|
58
|
+
project = @configuration.project
|
59
|
+
|
60
|
+
toBuild = ''
|
61
|
+
if workspace.nil?
|
62
|
+
toBuild = " -project '" + project + ".xcodeproj'"
|
63
|
+
else
|
64
|
+
toBuild = " -workspace '" + workspace + ".xcworkspace'"
|
65
|
+
end
|
66
|
+
|
67
|
+
return toBuild
|
68
|
+
end
|
69
|
+
|
70
|
+
# Runs tests for the specified file
|
71
|
+
#
|
72
|
+
# @param filename [String] the file you wish to run the tests for
|
73
|
+
# @note This method supports both workspace- and project-based environments
|
74
|
+
def test(filename)
|
75
|
+
scheme = @configuration.scheme
|
76
|
+
target = @configuration.target
|
77
|
+
xctool = @configuration.xctool_path
|
78
|
+
reporter = @configuration.reporter
|
79
|
+
suffix = @configuration.suffix
|
80
|
+
|
81
|
+
GALogger.log("Running tests for file " + filename + '...')
|
82
|
+
|
83
|
+
toBuild = buildArgument()
|
84
|
+
system("xcodebuild" + toBuild +
|
85
|
+
' -scheme ' + scheme +
|
86
|
+
' -sdk iphonesimulator' +
|
87
|
+
' test | xcpretty -tc', out: $stdout, err: :out)
|
88
|
+
end
|
89
|
+
end
|
data/lib/xctool_runner.rb
CHANGED
@@ -8,6 +8,16 @@ class XctoolRunner
|
|
8
8
|
def initialize(configuration)
|
9
9
|
@configuration=configuration
|
10
10
|
end
|
11
|
+
|
12
|
+
# Tells the runner to prepare the environment for a subsequent test run
|
13
|
+
#
|
14
|
+
# @param filename [String] the name of the file the caller wishes to test
|
15
|
+
#
|
16
|
+
# @note since xctool needs to build the tests every time, this method just calls build
|
17
|
+
# (see #build)
|
18
|
+
def prepareForFile(filename)
|
19
|
+
build()
|
20
|
+
end
|
11
21
|
|
12
22
|
# Builds the tests target through xctool
|
13
23
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guardian-angel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vittorio Monaco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filewatcher
|
@@ -38,7 +38,22 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.8'
|
41
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: xcpretty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
55
|
+
description: A file watcher for iOS developers that makes it quicker to iterate through
|
56
|
+
TDD
|
42
57
|
email: vittorio.monaco1@gmail.com
|
43
58
|
executables:
|
44
59
|
- guardian-angel
|
@@ -53,8 +68,9 @@ files:
|
|
53
68
|
- lib/ga_logger.rb
|
54
69
|
- lib/ga_runner.rb
|
55
70
|
- lib/guardian_angel.rb
|
71
|
+
- lib/xcodebuild_runner.rb
|
56
72
|
- lib/xctool_runner.rb
|
57
|
-
homepage:
|
73
|
+
homepage: https://github.com/vittoriom/GuardianAngel
|
58
74
|
licenses:
|
59
75
|
- MIT
|
60
76
|
metadata: {}
|