oats 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/oats/driver.rb +1 -2
- data/lib/oats/keywords.rb +21 -1
- data/lib/oats/mysql.rb +1 -1
- data/lib/oats/oats.rb +1 -1
- data/lib/oats/oats_lock.rb +11 -11
- data/lib/oats/oselenium.rb +9 -9
- data/lib/oats/test_case.rb +1 -1
- data/lib/oats/test_data.rb +1 -1
- data/lib/oats/version.rb +1 -1
- data/oats.gemspec +7 -7
- data/oats_ini.yml +1 -0
- data/oats_tests/Gemfile +5 -7
- data/oats_tests/aut_ini.yml +1 -1
- metadata +20 -6
- data/oats_tests/lib/business.rb +0 -28
data/lib/oats/driver.rb
CHANGED
@@ -45,13 +45,12 @@ module Oats
|
|
45
45
|
# Returns oats_info object containing execution results
|
46
46
|
def Driver.run(args)
|
47
47
|
unless ENV['HOSTNAME']
|
48
|
-
if
|
48
|
+
if RUBY_PLATFORM =~ /mswin32/
|
49
49
|
ENV['HOSTNAME'] = ENV['COMPUTERNAME']
|
50
50
|
else
|
51
51
|
ENV['HOSTNAME'] = `hostname`.chomp
|
52
52
|
end
|
53
53
|
end
|
54
|
-
ENV['OS'] ||= `uname`.chomp
|
55
54
|
|
56
55
|
Log4r::Logger.root.level = Log4r::DEBUG
|
57
56
|
Log4r::StdoutOutputter.new('console', :level=>1,
|
data/lib/oats/keywords.rb
CHANGED
@@ -49,10 +49,30 @@ module Oats
|
|
49
49
|
def process
|
50
50
|
# Class name comes from Oats.data oats_keywords_cleass, or in the case of XL files from TestCase ID
|
51
51
|
class_name = Oats.data('keywords.class') || File.basename(File.dirname(File.dirname(Oats.test.id)))
|
52
|
+
class_file = nil
|
52
53
|
begin
|
53
54
|
keywords_class = Kernel.const_get class_name
|
54
55
|
rescue NameError
|
55
|
-
|
56
|
+
class_file = Oats.data('keywords.class_file')
|
57
|
+
unless class_file # Try standard ruby conventions
|
58
|
+
class_file = class_name.dup
|
59
|
+
class_file.gsub!(/::/, '/')
|
60
|
+
class_file.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
61
|
+
class_file.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
62
|
+
class_file.tr!("-", "_")
|
63
|
+
class_file.downcase!
|
64
|
+
end
|
65
|
+
begin
|
66
|
+
Oats.info "Loading: '#{class_file}' for #{class_name}"
|
67
|
+
require class_file
|
68
|
+
begin
|
69
|
+
keywords_class = Kernel.const_get class_name
|
70
|
+
rescue NameError
|
71
|
+
raise OatsTestError, "Can not find class '#{class_name}' in class file: '#{class_file}'"
|
72
|
+
end
|
73
|
+
rescue LoadError
|
74
|
+
Oats.assert class_file.nil?, "Could not load Oats.data keywords.class_file '#{class_file}' for class '#{class_name}'."
|
75
|
+
end
|
56
76
|
end
|
57
77
|
oats_data('keywords',keywords_class).each do |action|
|
58
78
|
Oats.assert keywords_class.respond_to?(action),
|
data/lib/oats/mysql.rb
CHANGED
@@ -35,7 +35,7 @@ module Oats
|
|
35
35
|
sql_out_name = name + '.txt' unless sql_out_name
|
36
36
|
sql_out = File.join(test.result, sql_out_name) if sql_out_name
|
37
37
|
err_file = sql_out + '.err'
|
38
|
-
command = (
|
38
|
+
command = (RUBY_PLATFORM =~ /darwin'/ ? '/usr/local/mysql/bin/mysql' : 'mysql') +
|
39
39
|
" #{parameters(connect)} < #{mysql_input_file} > #{sql_out} 2> #{err_file}"
|
40
40
|
# $log.debug "Executing: #{command}"
|
41
41
|
$log.info "SQL: #{sql_input}" if sql_input
|
data/lib/oats/oats.rb
CHANGED
@@ -109,7 +109,7 @@ module Oats
|
|
109
109
|
# Returns captured file name if successful, or nil.
|
110
110
|
def Oats.system_capture
|
111
111
|
return if $selenium.nil? or # Snapshots are not supported on Ubuntu/Chrome
|
112
|
-
($oats['selenium']['browser_type'] == 'chrome' and
|
112
|
+
($oats['selenium']['browser_type'] == 'chrome' and RUBY_PLATFORM =~ /linux/)
|
113
113
|
ct = TestData.current_test
|
114
114
|
file = Util.file_unique(fn="page_screenshot.png", ct.result)
|
115
115
|
Oats.info "Will attempt to capture #{fn}."
|
data/lib/oats/oats_lock.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Manages a lock file indicating a OATS session is in process
|
2
|
-
require 'win32ole' if
|
2
|
+
require 'win32ole' if RUBY_PLATFORM =~ /mswin32/
|
3
3
|
module Oats
|
4
4
|
|
5
5
|
module OatsLock
|
@@ -14,7 +14,7 @@ module Oats
|
|
14
14
|
@@file_handle = File.open(in_progress_file, 'w')
|
15
15
|
my_pid = Process.pid.to_s
|
16
16
|
@@file_handle.puts my_pid
|
17
|
-
if
|
17
|
+
if RUBY_PLATFORM !~ /mswin32/ or ENV['TEMP'] =~ /^\/cygdrive/
|
18
18
|
# Leave file handle open for windows to detect and kill associated java, etc.
|
19
19
|
# processes using file handles.
|
20
20
|
@@file_handle.close
|
@@ -30,7 +30,7 @@ module Oats
|
|
30
30
|
def OatsLock.locked?(verify = nil)
|
31
31
|
return @@is_locked unless verify
|
32
32
|
@@is_locked = false
|
33
|
-
if
|
33
|
+
if RUBY_PLATFORM !~ /mswin32/ or ENV['TEMP'] =~ /^\/cygdrive/
|
34
34
|
if File.exist?(in_progress_file)
|
35
35
|
pids = IO.readlines(in_progress_file)
|
36
36
|
ruby_pid = pids.shift
|
@@ -140,7 +140,7 @@ module Oats
|
|
140
140
|
|
141
141
|
def OatsLock.find_matching_processes(proc_names)
|
142
142
|
matched = []
|
143
|
-
if
|
143
|
+
if RUBY_PLATFORM =~ /mswin32/
|
144
144
|
processes = WIN32OLE.connect("winmgmts://").ExecQuery("select * from win32_process")
|
145
145
|
# for process in processes do
|
146
146
|
# for property in process.Properties_ do
|
@@ -154,22 +154,22 @@ module Oats
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
else
|
157
|
-
pscom =
|
157
|
+
pscom = RUBY_PLATFORM =~ /linux/ ? 'ps lxww' : 'ps -ef'
|
158
158
|
`#{pscom}`.split("\n").each do |lvar|
|
159
159
|
line = lvar.chomp
|
160
|
-
case
|
161
|
-
when
|
160
|
+
case RUBY_PLATFORM
|
161
|
+
when /darwin/ # ps -ef output
|
162
162
|
pid = line[5..11]
|
163
163
|
next if pid.to_i == 0
|
164
164
|
ppid = line[12..16]
|
165
165
|
proc_name = line[50..-1]
|
166
|
-
when
|
166
|
+
when /linux/ # ps ww output
|
167
167
|
pid = line[7..12]
|
168
168
|
next if pid.to_i == 0
|
169
169
|
ppid = line[13..18]
|
170
170
|
proc_name = line[69..-1]
|
171
171
|
else
|
172
|
-
raise OatError, "Do not know how to parse ps output from #{
|
172
|
+
raise OatError, "Do not know how to parse ps output from #{RUBY_PLATFORM}"
|
173
173
|
end
|
174
174
|
next unless pid
|
175
175
|
matched.push [pid.strip, proc_name.strip, ppid.strip, line.strip] if proc_name =~ proc_names
|
@@ -189,7 +189,7 @@ module Oats
|
|
189
189
|
|
190
190
|
# Kill all selenium automation chrome jobs on MacOS. Assumes MacOS is for development only, not OCC.
|
191
191
|
# Will cause problems if multiple agents are run on MacOS
|
192
|
-
if
|
192
|
+
if RUBY_PLATFORM =~ /darwin/
|
193
193
|
chrome_automation_procs = OatsLock.find_matching_processes(/ Chrome .* --dom-automation/)
|
194
194
|
chrome_automation_procs.each do |pid,proc_name,ppid|
|
195
195
|
OatsLock.kill_pid pid
|
@@ -222,7 +222,7 @@ module Oats
|
|
222
222
|
@@file_handle = nil
|
223
223
|
@@is_locked = true
|
224
224
|
else # Doesn't return status properly for non-windows, just resets the lock
|
225
|
-
if $oats_execution['agent'].nil? and
|
225
|
+
if $oats_execution['agent'].nil? and RUBY_PLATFORM !~ /mswin32/ and File.exist?(in_progress_file)
|
226
226
|
pids = IO.readlines(in_progress_file)
|
227
227
|
current_pid = pids.shift
|
228
228
|
pids.each { |pid| OatsLock.kill_pid(pid.chomp) } # Legacy firefox
|
data/lib/oats/oselenium.rb
CHANGED
@@ -45,13 +45,13 @@ module Oats
|
|
45
45
|
if browser_type == 'firefox'
|
46
46
|
$oats_global['download_dir'] = $oats['execution']['dir_results'] + '/downloads'
|
47
47
|
elsif Oats.data("selenium.default_downloads")
|
48
|
-
$oats_global['download_dir'] = File.join(ENV[
|
49
|
-
$oats_global['download_dir'].gsub!('\\','/') if
|
48
|
+
$oats_global['download_dir'] = File.join(ENV[ RUBY_PLATFORM =~ /mswin32/ ? 'USERPROFILE' : 'HOME'], 'Downloads')
|
49
|
+
$oats_global['download_dir'].gsub!('\\','/') if RUBY_PLATFORM =~ /mswin32/
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
download_dir = $oats_global['download_dir'].gsub('/','\\\\') if $oats_global['download_dir'] and
|
54
|
-
|
54
|
+
RUBY_PLATFORM =~ /mswin32/
|
55
55
|
download_dir ||= $oats_global['download_dir']
|
56
56
|
case browser_type
|
57
57
|
when 'firefox'
|
@@ -69,10 +69,10 @@ module Oats
|
|
69
69
|
profile = Selenium::WebDriver::Chrome::Profile.new
|
70
70
|
profile['download.prompt_for_download'] = false
|
71
71
|
profile['download.default_directory'] = download_dir
|
72
|
-
unless $oats_global['browser_path']
|
73
|
-
vpath = File.join($oats['_']['vendor'], ENV['OS'], 'chromedriver' + (
|
74
|
-
$oats_global['browser_path'] = vpath if File.exist?(vpath)
|
75
|
-
end
|
72
|
+
# unless $oats_global['browser_path']
|
73
|
+
# vpath = File.join($oats['_']['vendor'], ENV['OS'], 'chromedriver' + (RUBY_PLATFORM =~ /mswin32/ ? '.exe' : '') )
|
74
|
+
# $oats_global['browser_path'] = vpath if File.exist?(vpath)
|
75
|
+
# end
|
76
76
|
end
|
77
77
|
FileUtils.rm_f Dir.glob(File.join($oats_global['download_dir'],'*')) if $oats_global['download_dir']
|
78
78
|
Oats.info "Browser type: #{browser_type.inspect}, profile: #{profile.inspect}, path: #{$oats_global["browser_path"].inspect}"
|
@@ -127,9 +127,9 @@ module Oats
|
|
127
127
|
file.sub!(ENV['OATS_HOME'], $oats['selenium']['remote_webdriver']['oats_dir'])
|
128
128
|
file_os = $oats['selenium']['remote_webdriver']['os']
|
129
129
|
else
|
130
|
-
file_os =
|
130
|
+
file_os = RUBY_PLATFORM
|
131
131
|
end
|
132
|
-
file_os
|
132
|
+
file_os =~ /mswin32/ ? file.gsub('/','\\') : file
|
133
133
|
end
|
134
134
|
|
135
135
|
def Oselenium.reset
|
data/lib/oats/test_case.rb
CHANGED
@@ -432,7 +432,7 @@ module Oats
|
|
432
432
|
out_contents = IO.read(file_out).gsub(/\s/,'')
|
433
433
|
unless ok_contents == out_contents
|
434
434
|
err = "File in out folder did not match out folder in: #{file_ok}"
|
435
|
-
diff_lines = `diff -b '#{file_ok}' '#{file_out}'` unless
|
435
|
+
diff_lines = `diff -b '#{file_ok}' '#{file_out}'` unless RUBY_PLATFORM =~ /mswin32/
|
436
436
|
end
|
437
437
|
else
|
438
438
|
err = "Extra output [#{file}] missing from: #{test_ok_out}"
|
data/lib/oats/test_data.rb
CHANGED
@@ -62,7 +62,7 @@ module Oats
|
|
62
62
|
extn = File.extname(test_file)
|
63
63
|
extn = nil if extn == ''
|
64
64
|
found_file = catch :found_file do
|
65
|
-
if
|
65
|
+
if RUBY_PLATFORM =~ /mswin32/ ? test_file[1] == ?: : test_file[0] == ?/ # absolute path
|
66
66
|
# Try exact match
|
67
67
|
throw(:found_file, test_file) if File.exist?(test_file) and (is_dir or not FileTest.directory?(test_file))
|
68
68
|
|
data/lib/oats/version.rb
CHANGED
data/oats.gemspec
CHANGED
@@ -16,25 +16,25 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
# s.test_files = ["test/test_cgi_wrapper.rb" ]
|
19
|
-
s.executables = %w{oats}
|
19
|
+
s.executables = %w{oats occ}
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
# s.extra_rdoc_files = ["CHANGELOG", "COPYING", "lib/
|
22
|
+
# s.extra_rdoc_files = ["CHANGELOG", "COPYING", "lib/oats/oats.rb", "LICENSE", "README"]
|
23
23
|
# s.has_rdoc = true
|
24
|
-
# s.homepage = %q{http://
|
25
|
-
# s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "
|
24
|
+
# s.homepage = %q{http://oats .org}
|
25
|
+
# s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Oats", "--main", "README"
|
26
26
|
s.date = %q{2012-05-22}
|
27
27
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
28
28
|
|
29
29
|
s.add_dependency 'log4r'
|
30
|
-
s.add_dependency 'net-http-persistent' unless RUBY_VERSION
|
30
|
+
s.add_dependency 'net-http-persistent' unless RUBY_VERSION =~ /^1.9/ # Speed up 1.8 connections
|
31
31
|
|
32
|
-
if
|
32
|
+
if RUBY_PLATFORM =~ /mswin32/ # Assume won't use the agent
|
33
33
|
s.add_dependency 'win32-process'
|
34
34
|
else
|
35
35
|
s.add_dependency 'json'
|
36
36
|
s.add_dependency 'em-http-request'
|
37
|
-
if
|
37
|
+
if RUBY_PLATFORM =~ /linux/ # Seems to be needed by Ubuntu
|
38
38
|
s.add_dependency 'execjs'
|
39
39
|
s.add_dependency 'therubyracer'
|
40
40
|
end
|
data/oats_ini.yml
CHANGED
@@ -242,6 +242,7 @@ sql:
|
|
242
242
|
# <oats_data>
|
243
243
|
#<class>:
|
244
244
|
keywords:
|
245
|
+
class_file: # File name of the class so it can be 'require'd if using a non-standard name
|
245
246
|
class: # Class file containing methods for each keyword
|
246
247
|
list: # Optional list name under which to find the keywords and data in Oats.data
|
247
248
|
|
data/oats_tests/Gemfile
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
|
1
|
+
source "http://rubygems.org"
|
2
2
|
|
3
3
|
# OATS Framework
|
4
4
|
gem 'oats' unless defined?(OATS_GEM_IS_ALREADY_INCLUDED)
|
5
|
-
#
|
5
|
+
gem 'spreadsheet' # If you want to run XL based tests
|
6
6
|
|
7
|
-
## List GEMs needed by the AUT goes here
|
8
|
-
##
|
9
|
-
## To run XL based tests
|
10
|
-
gem 'spreadsheet'
|
11
|
-
#require 'sample_xl_lists' # Include XL based classes to be used.
|
12
7
|
#
|
8
|
+
# List GEMs needed by the AUT here, and require them in your test classes
|
9
|
+
#
|
10
|
+
|
13
11
|
gem 'selenium-webdriver' # To run WebDriver tests
|
14
12
|
gem 'json' # To run WebDriver tests w/o ok_json to improve performance
|
15
13
|
#
|
data/oats_tests/aut_ini.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# For full documentation on OATS, please refer to https://github.com/latasoy/oats
|
2
2
|
|
3
3
|
keywords:
|
4
|
-
class: # Class
|
4
|
+
class: # Class name containing methods for each keyword
|
5
5
|
list: # List name under which to find the keywords and data in Oats.data
|
6
6
|
|
7
7
|
SampleXlLists:
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Levent Atasoy
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
35
|
+
name: net-http-persistent
|
36
36
|
prerelease: false
|
37
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
38
|
none: false
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
49
|
+
name: json
|
50
50
|
prerelease: false
|
51
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
@@ -59,11 +59,26 @@ dependencies:
|
|
59
59
|
version: "0"
|
60
60
|
type: :runtime
|
61
61
|
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: em-http-request
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
62
76
|
description: A flexible automated system integration regression test framework.
|
63
77
|
email:
|
64
78
|
- levent.atasoy@gmail.com
|
65
79
|
executables:
|
66
80
|
- oats
|
81
|
+
- occ
|
67
82
|
extensions: []
|
68
83
|
|
69
84
|
extra_rdoc_files: []
|
@@ -243,7 +258,6 @@ files:
|
|
243
258
|
- oats_tests/examples/testFileLocationUnitTests/testDir2/t1.yml
|
244
259
|
- oats_tests/examples/testFileLocationUnitTests/unitTestList.yml
|
245
260
|
- oats_tests/examples/testFileLocationUnitTests/yml_driver.rb
|
246
|
-
- oats_tests/lib/business.rb
|
247
261
|
- oats_tests/lib/sample_xl_lists.rb
|
248
262
|
- test/common_test_unit_setup.rb
|
249
263
|
- test/test_basic.rb
|
data/oats_tests/lib/business.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'oats_x'
|
2
|
-
class Business < OatsX
|
3
|
-
|
4
|
-
def self.common(c)
|
5
|
-
Oats.info "Executing #{c} " + Oats.xl.inspect
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.component1
|
9
|
-
self.common 'component1'
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.component2
|
14
|
-
self.common 'component2'
|
15
|
-
# selenium = Oats.browser('http://google.com')
|
16
|
-
# selenium.type("id=gbqfq", 'xxxx')
|
17
|
-
# selenium.click("id=gbqfb")
|
18
|
-
#
|
19
|
-
# selenium.find_element(:id, "gbqfq").clear
|
20
|
-
# selenium.find_element(:id, "gbqfq").send_keys "xxxx"
|
21
|
-
# selenium.find_element(:id, "gbqfb").click
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.component3
|
25
|
-
self.common 'component3'
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|