earlgrey 0.0.1 → 0.0.2
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/bin/earlgrey +5 -0
- data/lib/earlgrey.rb +1 -1
- data/lib/earlgrey/cli.rb +43 -0
- data/lib/earlgrey/configure_earlgrey_pods.rb +332 -0
- data/lib/earlgrey/earlgrey.rb +10 -0
- data/lib/earlgrey/files/BridgingHeader.h +1 -0
- data/lib/earlgrey/files/EarlGrey.swift +78 -0
- data/lib/earlgrey/version.rb +2 -2
- metadata +39 -13
- data/.gitignore +0 -1
- data/Gemfile +0 -6
- data/LICENSE +0 -598
- data/README.md +0 -1
- data/Thorfile +0 -7
- data/earlgrey.gemspec +0 -27
- data/release_notes.md +0 -0
- data/todo/configure_earlgrey_pods.rb +0 -194
- data/todo/swift_config.rb +0 -11
data/README.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# earlgrey
|
data/Thorfile
DELETED
data/earlgrey.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative 'lib/earlgrey/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.required_ruby_version = '>= 2.1.9'
|
5
|
-
|
6
|
-
s.name = 'earlgrey'
|
7
|
-
s.version = EarlGrey::VERSION
|
8
|
-
s.date = EarlGrey::DATE
|
9
|
-
s.license = 'Apache-2.0'
|
10
|
-
s.description = s.summary = 'EarlGrey helper gem'
|
11
|
-
s.description += '.' # avoid identical warning
|
12
|
-
s.authors = s.email = ['code@bootstraponline.com']
|
13
|
-
s.homepage = 'https://github.com/bootstraponline/earlgrey'
|
14
|
-
s.require_paths = ['lib']
|
15
|
-
|
16
|
-
s.add_runtime_dependency 'colored', '>= 1.2'
|
17
|
-
s.add_runtime_dependency 'xcodeproj', '>= 0.28.2'
|
18
|
-
|
19
|
-
s.add_development_dependency 'rspec', '>= 3.4.0'
|
20
|
-
s.add_development_dependency 'appium_thor', '>= 1.0.1'
|
21
|
-
s.add_development_dependency 'rubocop', '>= 0.39.0'
|
22
|
-
s.add_development_dependency 'coveralls', '~> 0.8.13'
|
23
|
-
|
24
|
-
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
-
f.match(%r{^(spec)/})
|
26
|
-
end
|
27
|
-
end
|
data/release_notes.md
DELETED
File without changes
|
@@ -1,194 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
#
|
3
|
-
# Copyright 2016 Google Inc.
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
require 'xcodeproj'
|
18
|
-
EARLGREY_TARGET_NAME = 'EarlGrey'
|
19
|
-
|
20
|
-
def configure_for_earlgrey(project_name, test_target, scheme_file)
|
21
|
-
puts ("Checking and Updating " + project_name + " for EarlGrey.").blue
|
22
|
-
if (!File.exist?(project_name + '.xcodeproj'))
|
23
|
-
raise "The target's xcodeproj file could not be found. Please check if "\
|
24
|
-
"the correct PROJECT_NAME is being passed in the Podfile. Current "\
|
25
|
-
"PROJECT_NAME is: " + project_name
|
26
|
-
end
|
27
|
-
|
28
|
-
user_project = Xcodeproj::Project.open(project_name + '.xcodeproj')
|
29
|
-
|
30
|
-
# Add a Test Action to the User Project Scheme.
|
31
|
-
scheme = modify_scheme_for_actions(project_name, user_project, scheme_file)
|
32
|
-
|
33
|
-
# Add a Copy Files Build Phase for EarlGrey.framework to embed it into the app under test.
|
34
|
-
add_earlgrey_copy_files_script(user_project, test_target)
|
35
|
-
|
36
|
-
if not scheme.nil?
|
37
|
-
save_earlgrey_scheme_changes(scheme)
|
38
|
-
end
|
39
|
-
puts ("EarlGrey setup complete. You can use the Test Target : " + test_target +
|
40
|
-
" for EarlGrey testing.").blue
|
41
|
-
end
|
42
|
-
|
43
|
-
# Scheme changes to ensure that EarlGrey is correctly loaded before main() is called.
|
44
|
-
def modify_scheme_for_actions(project_name, user_project, scheme_filename)
|
45
|
-
# If you do not pass on a scheme name, we set it to the project name itself.
|
46
|
-
if scheme_filename.to_s == ''
|
47
|
-
scheme_filename = project_name
|
48
|
-
end
|
49
|
-
|
50
|
-
xcdata_dir = Xcodeproj::XCScheme.user_data_dir(user_project.path)
|
51
|
-
if not File.exist?(File.join(xcdata_dir, scheme_filename).to_s)
|
52
|
-
xcdata_dir = Xcodeproj::XCScheme.shared_data_dir(user_project.path)
|
53
|
-
end
|
54
|
-
|
55
|
-
if not File.exist?(File.join(xcdata_dir, scheme_filename).to_s)
|
56
|
-
raise "The required scheme \"" + scheme_filename +"\" could not be found."
|
57
|
-
" Please ensure that the required scheme file exists within your"\
|
58
|
-
" project directory."
|
59
|
-
end
|
60
|
-
scheme = Xcodeproj::XCScheme.new File.join(xcdata_dir, scheme_filename)
|
61
|
-
test_action_key = 'DYLD_INSERT_LIBRARIES'
|
62
|
-
test_action_value = '@executable_path/EarlGrey.framework/EarlGrey'
|
63
|
-
if not scheme.test_action.xml_element.to_s.include? test_action_value
|
64
|
-
scheme =
|
65
|
-
add_environment_variables_to_test_action_scheme(scheme_filename,
|
66
|
-
scheme,
|
67
|
-
test_action_key,
|
68
|
-
test_action_value)
|
69
|
-
end
|
70
|
-
|
71
|
-
return scheme
|
72
|
-
end
|
73
|
-
|
74
|
-
# Load the EarlGrey framework when the app binary is loaded by
|
75
|
-
# the dynamic loader, before the main() method is called.
|
76
|
-
def add_environment_variables_to_test_action_scheme(scheme_filename,
|
77
|
-
scheme,
|
78
|
-
test_action_key,
|
79
|
-
test_action_value)
|
80
|
-
test_action = scheme.test_action
|
81
|
-
if (scheme.test_action.xml_element.to_s.include? test_action_key) ||
|
82
|
-
(scheme.launch_action.xml_element.to_s.include? test_action_key)
|
83
|
-
puts ("\n//////////////////// EARLGREY SCHEME ISSUE ////////////////////\n"\
|
84
|
-
"EarlGrey failed to modify the Test Action part of the scheme: " + scheme_filename + "\n"\
|
85
|
-
+ "for one of following reasons:\n\n"\
|
86
|
-
"1) DYLD_INSERT_LIBRARIES is already defined under Environment Variables of\n"\
|
87
|
-
"the Test Action.\n"\
|
88
|
-
"2) Run Action's environment variables are used for Test Action.\n\n"\
|
89
|
-
"To ensure correct functioning of EarlGrey, please manually add the\n"\
|
90
|
-
"following under Test Action's Environment Variables of the scheme:" + scheme_filename + "\n"\
|
91
|
-
"Environment Variables or EarlGrey's location will not be found.\n"\
|
92
|
-
"Name: DYLD_INSERT_LIBRARIES\n"\
|
93
|
-
"Value: @executable_path/EarlGrey.framework/EarlGrey\n"\
|
94
|
-
"///////////////////////////////////////////////////////////////\n\n").yellow
|
95
|
-
return
|
96
|
-
end
|
97
|
-
puts "Adding EarlGrey Framework Location as an Environment Variable "
|
98
|
-
"in the App Project's Test Target's Scheme Test Action."
|
99
|
-
|
100
|
-
# Check if the test action uses the run action's environment variables and arguments.
|
101
|
-
launch_action_env_args_present = false
|
102
|
-
if (scheme.test_action.xml_element.to_s.include? 'shouldUseLaunchSchemeArgsEnv') &&
|
103
|
-
((scheme.launch_action.xml_element.to_s.include? '<EnvironmentVariables>') ||
|
104
|
-
(scheme.launch_action.xml_element.to_s.include? '<CommandLineArguments>'))
|
105
|
-
launch_action_env_args_present = true
|
106
|
-
end
|
107
|
-
|
108
|
-
test_action_isEnabled = 'YES'
|
109
|
-
test_action.should_use_launch_scheme_args_env = false
|
110
|
-
|
111
|
-
# If no environment variables are set, then create the element itself.
|
112
|
-
if not (scheme.test_action.xml_element.to_s.include? '<EnvironmentVariables>')
|
113
|
-
scheme.test_action.xml_element.add_element('EnvironmentVariables')
|
114
|
-
end
|
115
|
-
|
116
|
-
# If Launch Action Arguments are present and none are present in the test
|
117
|
-
# action, then please add them in.
|
118
|
-
if (scheme.launch_action.xml_element.to_s.include? '<CommandLineArguments>') &&
|
119
|
-
!(scheme.test_action.xml_element.to_s.include? '<CommandLineArguments>')
|
120
|
-
scheme.test_action.xml_element.add_element('CommandLineArguments')
|
121
|
-
end
|
122
|
-
|
123
|
-
# Create a new environment variable and add it to the Environment Variables.
|
124
|
-
test_action_env_vars = scheme.test_action.xml_element.elements['EnvironmentVariables']
|
125
|
-
test_action_args = scheme.test_action.xml_element.elements['CommandLineArguments']
|
126
|
-
|
127
|
-
earl_grey_environment_variable = REXML::Element.new "EnvironmentVariable"
|
128
|
-
earl_grey_environment_variable.attributes['key'] = test_action_key
|
129
|
-
earl_grey_environment_variable.attributes['value'] = test_action_value
|
130
|
-
earl_grey_environment_variable.attributes['isEnabled'] = test_action_isEnabled
|
131
|
-
test_action_env_vars.add_element(earl_grey_environment_variable)
|
132
|
-
|
133
|
-
# If any environment variables or arguments were being used in the test action by
|
134
|
-
# being copied from the launch (run) action then copy them over to the test action
|
135
|
-
# along with the EarlGrey environment variable.
|
136
|
-
if (launch_action_env_args_present)
|
137
|
-
launch_action_env_vars = scheme.launch_action.xml_element.elements['EnvironmentVariables']
|
138
|
-
launch_action_args = scheme.launch_action.xml_element.elements['CommandLineArguments']
|
139
|
-
|
140
|
-
# Add in the Environment Variables
|
141
|
-
launch_action_env_vars.elements.each('EnvironmentVariable') do |launch_action_env_var|
|
142
|
-
environment_variable = REXML::Element.new 'EnvironmentVariable'
|
143
|
-
environment_variable.attributes['key'] = launch_action_env_var.attributes['key']
|
144
|
-
environment_variable.attributes['value'] = launch_action_env_var.attributes['value']
|
145
|
-
environment_variable.attributes['isEnabled'] = launch_action_env_var.attributes['isEnabled']
|
146
|
-
test_action_env_vars.add_element(environment_variable)
|
147
|
-
end
|
148
|
-
|
149
|
-
#Add in the Arguments
|
150
|
-
launch_action_args.elements.each('CommandLineArgument') do |launch_action_arg|
|
151
|
-
argument = REXML::Element.new 'CommandLineArgument'
|
152
|
-
argument.attributes['argument'] = launch_action_arg.attributes['argument']
|
153
|
-
argument.attributes['isEnabled'] = launch_action_arg.attributes['isEnabled']
|
154
|
-
test_action_args.add_element(argument)
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|
158
|
-
scheme.test_action = test_action
|
159
|
-
return scheme
|
160
|
-
end
|
161
|
-
|
162
|
-
# Generates a copy files build phase to embed the EarlGrey framework into
|
163
|
-
# the app under test.
|
164
|
-
def add_earlgrey_copy_files_script(user_project, test_target)
|
165
|
-
user_project.targets.each do |target|
|
166
|
-
earlgrey_copy_files_phase_name = 'EarlGrey Copy Files'
|
167
|
-
if target.name == test_target
|
168
|
-
earlgrey_copy_files_exists = false
|
169
|
-
target.copy_files_build_phases.each do |copy_files_phase|
|
170
|
-
if copy_files_phase.name = earlgrey_copy_files_phase_name
|
171
|
-
earlgrey_copy_files_exists = true
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
if earlgrey_copy_files_exists == false
|
176
|
-
new_copy_files_phase = target.new_copy_files_build_phase(earlgrey_copy_files_phase_name)
|
177
|
-
new_copy_files_phase.dst_path = '$(TEST_HOST)/../'
|
178
|
-
new_copy_files_phase.dst_subfolder_spec = '0'
|
179
|
-
file_ref =
|
180
|
-
user_project.products_group.new_file('${SRCROOT}/Pods/EarlGrey/EarlGrey-1.0.0/EarlGrey.framework')
|
181
|
-
file_ref.source_tree = 'SRCROOT'
|
182
|
-
build_file = new_copy_files_phase.add_file_reference(file_ref, true)
|
183
|
-
build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy'] }
|
184
|
-
user_project.save()
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
# Save the scheme changes. This is done here to prevent any irreversible changes in case
|
191
|
-
# of an exception being thrown.
|
192
|
-
def save_earlgrey_scheme_changes(scheme)
|
193
|
-
scheme.save!
|
194
|
-
end
|
data/todo/swift_config.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'xcodeproj'
|
3
|
-
require 'colored'
|
4
|
-
require_relative 'configure_earlgrey_pods.rb'
|
5
|
-
|
6
|
-
# xcodebuild -list # lists project/targets/scheme
|
7
|
-
PROJECT_NAME = 'Example'
|
8
|
-
TEST_TARGET_SWIFT = 'ExampleEarlGrey2'
|
9
|
-
SCHEME_FILE_SWIFT = 'ExampleEarlGrey2.xcscheme'
|
10
|
-
|
11
|
-
configure_for_earlgrey(PROJECT_NAME, TEST_TARGET_SWIFT, SCHEME_FILE_SWIFT)
|