soda 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/Soda.rb +179 -187
- data/lib/sodainfo.rb +1 -1
- metadata +4 -4
data/lib/Soda.rb
CHANGED
@@ -197,27 +197,27 @@ class Soda
|
|
197
197
|
|
198
198
|
###############################################################################
|
199
199
|
# RestartGlobalTime -- Method
|
200
|
-
#
|
200
|
+
# This method reset the global time, for the watchdog timer.
|
201
201
|
#
|
202
202
|
# Input:
|
203
|
-
#
|
203
|
+
# None.
|
204
204
|
#
|
205
205
|
# Output:
|
206
|
-
#
|
206
|
+
# None.
|
207
207
|
#
|
208
208
|
###############################################################################
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
209
|
+
def RestartGlobalTime()
|
210
|
+
$mutex.synchronize {
|
211
|
+
$global_time = Time.now()
|
212
|
+
}
|
213
|
+
end
|
214
214
|
|
215
215
|
###############################################################################
|
216
216
|
###############################################################################
|
217
217
|
def NewBrowser()
|
218
218
|
err = 0
|
219
219
|
|
220
|
-
|
220
|
+
RestartGlobalTime()
|
221
221
|
|
222
222
|
if ( @current_os =~ /WINDOWS/i &&
|
223
223
|
@params['browser'] =~ /ie|firefox/i )
|
@@ -823,7 +823,7 @@ class Soda
|
|
823
823
|
@browser.close()
|
824
824
|
sleep(1)
|
825
825
|
|
826
|
-
|
826
|
+
RestartGlobalTime()
|
827
827
|
|
828
828
|
err = NewBrowser()
|
829
829
|
if (err != 0)
|
@@ -873,14 +873,14 @@ class Soda
|
|
873
873
|
fd = Dir.open(file)
|
874
874
|
fd.each do |f|
|
875
875
|
files.push("#{file}/#{f}") if (f =~ /\.xml$/i)
|
876
|
-
#
|
876
|
+
# @rep.IncTestTotalCount() if (f !~ /lib/i)
|
877
877
|
end
|
878
878
|
fd.close()
|
879
879
|
|
880
880
|
if (files.empty?)
|
881
881
|
@rep.log("No tests found in directory: '#{file}'!\n",
|
882
882
|
SodaUtils::WARN)
|
883
|
-
|
883
|
+
@rep.IncTestWarningCount()
|
884
884
|
return nil
|
885
885
|
end
|
886
886
|
|
@@ -913,9 +913,9 @@ class Soda
|
|
913
913
|
PrintDebug("Test since last restart: #{@non_lib_test_count +1}.\n")
|
914
914
|
if (results != 0)
|
915
915
|
@FAILEDTESTS.push(@currentTestFile)
|
916
|
-
|
917
|
-
|
918
|
-
|
916
|
+
@rep.IncFailedTest()
|
917
|
+
else
|
918
|
+
@rep.IncTestPassedCount() if (file !~ /lib/i)
|
919
919
|
end
|
920
920
|
@currentTestFile = parent_test_file
|
921
921
|
else
|
@@ -946,7 +946,7 @@ class Soda
|
|
946
946
|
tmp_file = File.basename(test_file)
|
947
947
|
if (tmp_file =~ /#{bhash['testfile']}/)
|
948
948
|
@rep.log("Blocklist: blocking file: \"#{test_file}\".\n")
|
949
|
-
|
949
|
+
@rep.IncBlockedTest()
|
950
950
|
result = true
|
951
951
|
break
|
952
952
|
end
|
@@ -1419,7 +1419,7 @@ class Soda
|
|
1419
1419
|
else
|
1420
1420
|
PrintDebug("For some reason I got a nill @browser object!",
|
1421
1421
|
SodaUtils::WARN)
|
1422
|
-
|
1422
|
+
@rep.IncTestWarningCount()
|
1423
1423
|
result['browser_closed'] = true
|
1424
1424
|
end
|
1425
1425
|
when "refresh"
|
@@ -1578,7 +1578,7 @@ class Soda
|
|
1578
1578
|
else
|
1579
1579
|
@rep.log("Found requires event without any children!\n",
|
1580
1580
|
SodaUtils::WARN)
|
1581
|
-
|
1581
|
+
@rep.IncTestWarningCount()
|
1582
1582
|
end
|
1583
1583
|
end
|
1584
1584
|
end
|
@@ -1780,7 +1780,7 @@ class Soda
|
|
1780
1780
|
#
|
1781
1781
|
###############################################################################
|
1782
1782
|
def eventScript(event)
|
1783
|
-
|
1783
|
+
results = 0
|
1784
1784
|
|
1785
1785
|
if (event.key?('file'))
|
1786
1786
|
# specified a new csv to file
|
@@ -1796,11 +1796,11 @@ class Soda
|
|
1796
1796
|
parent_script = @currentTestFile
|
1797
1797
|
@currentTestFile = event['file']
|
1798
1798
|
results = handleEvents(script)
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1799
|
+
if (@currentTestFile !~ /lib/i && results != 0)
|
1800
|
+
@rep.IncFailedTest()
|
1801
|
+
else
|
1802
|
+
@rep.IncTestPassedCount() if (@currentTestFile !~ /lib/i)
|
1803
|
+
end
|
1804
1804
|
@currentTestFile = parent_script
|
1805
1805
|
else
|
1806
1806
|
msg = "Failed opening script file: \"#{event['file']}\"!\n"
|
@@ -1931,7 +1931,7 @@ JSCode
|
|
1931
1931
|
def eventWait(event)
|
1932
1932
|
result = false
|
1933
1933
|
|
1934
|
-
|
1934
|
+
RestartGlobalTime()
|
1935
1935
|
|
1936
1936
|
if ( event.key?('condition') &&
|
1937
1937
|
getStringBool(event['condition']) &&
|
@@ -1955,7 +1955,7 @@ JSCode
|
|
1955
1955
|
result = true
|
1956
1956
|
end
|
1957
1957
|
|
1958
|
-
|
1958
|
+
RestartGlobalTime()
|
1959
1959
|
|
1960
1960
|
return result
|
1961
1961
|
end
|
@@ -2129,15 +2129,15 @@ JSCode
|
|
2129
2129
|
end
|
2130
2130
|
|
2131
2131
|
if (event.key?("alert") )
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2132
|
+
if (event['alert'] =~ /true/i)
|
2133
|
+
@rep.log("Enabling Alert Hack\n")
|
2134
|
+
fieldType.alertHack(true, true)
|
2135
|
+
else
|
2136
|
+
fieldType.alertHack(false, false)
|
2137
|
+
@rep.log("Disabeling alert!\n")
|
2138
|
+
PrintDebug("eventFieldAction: Finished.\n")
|
2139
|
+
return
|
2140
|
+
end
|
2141
2141
|
end
|
2142
2142
|
|
2143
2143
|
if (event.key?("jscriptevent"))
|
@@ -2184,10 +2184,10 @@ JSCode
|
|
2184
2184
|
else
|
2185
2185
|
@rep.log("Found unsupported value for <textfield clear" +
|
2186
2186
|
"=\"true/false\" />!\n", SodaUtils::WARN)
|
2187
|
-
|
2187
|
+
@rep.IncTestWarningCount()
|
2188
2188
|
@rep.log("Unsupported clear value =>" +
|
2189
2189
|
" \"#{event['clear']}\".\n", SodaUtils::WARN)
|
2190
|
-
|
2190
|
+
@rep.IncTestWarningCount()
|
2191
2191
|
end
|
2192
2192
|
end
|
2193
2193
|
when "focus"
|
@@ -2255,7 +2255,7 @@ JSCode
|
|
2255
2255
|
else
|
2256
2256
|
msg = "Failed to find supported field action.\n"
|
2257
2257
|
@rep.log(msg, SodaUtils::WARN)
|
2258
|
-
|
2258
|
+
@rep.IncTestWarningCount()
|
2259
2259
|
e_dump = SodaUtils.DumpEvent(event)
|
2260
2260
|
@rep.log("Event Dump: #{e_dump}\n", SodaUtils::EVENT)
|
2261
2261
|
end
|
@@ -2409,7 +2409,7 @@ JSCode
|
|
2409
2409
|
fieldType = nil
|
2410
2410
|
|
2411
2411
|
event = SodaUtils.ConvertOldAssert(event, @rep, @currentTestFile)
|
2412
|
-
|
2412
|
+
RestartGlobalTime()
|
2413
2413
|
crazyEvilIETabHack()
|
2414
2414
|
|
2415
2415
|
if (event.key?('set') && event['set'].is_a?(String) &&
|
@@ -2616,11 +2616,11 @@ JSCode
|
|
2616
2616
|
|
2617
2617
|
if (exception_event != nil)
|
2618
2618
|
@rep.log("Running Exception Handler.\n", SodaUtils::WARN)
|
2619
|
-
|
2619
|
+
@rep.IncTestWarningCount()
|
2620
2620
|
@exceptionExit = false
|
2621
2621
|
handleEvents(exception_event['children'])
|
2622
2622
|
@rep.log("Finished Exception Handler.\n", SodaUtils::WARN)
|
2623
|
-
|
2623
|
+
@rep.IncTestWarningCount()
|
2624
2624
|
@exceptionExit = true
|
2625
2625
|
end
|
2626
2626
|
|
@@ -2710,16 +2710,16 @@ JSCode
|
|
2710
2710
|
@rep.ReportFailure(msg)
|
2711
2711
|
PrintDebug("Global Time was: #{$global_time}\n")
|
2712
2712
|
PrintDebug("Timeout Time was: #{time_check}\n")
|
2713
|
-
|
2714
|
-
|
2715
|
-
|
2716
|
-
|
2717
|
-
|
2718
|
-
|
2719
|
-
|
2720
|
-
|
2721
|
-
|
2722
|
-
|
2713
|
+
@rep.IncTestWatchDogCount()
|
2714
|
+
begin
|
2715
|
+
result_dir = @rep.GetResultDir()
|
2716
|
+
shooter = SodaScreenShot.new(result_dir)
|
2717
|
+
image_file = shooter.GetOutputFile()
|
2718
|
+
@rep.log("ScreenShot taken: #{image_file}\n")
|
2719
|
+
rescue Excaption => e
|
2720
|
+
@rep.ReportException(e)
|
2721
|
+
ensure
|
2722
|
+
end
|
2723
2723
|
|
2724
2724
|
result = -1
|
2725
2725
|
thread_soda.exit()
|
@@ -2735,12 +2735,12 @@ JSCode
|
|
2735
2735
|
|
2736
2736
|
if (result != 0)
|
2737
2737
|
master_result = -1
|
2738
|
-
|
2739
|
-
|
2738
|
+
else
|
2739
|
+
@rep.IncTestPassedCount()
|
2740
2740
|
end
|
2741
2741
|
else
|
2742
2742
|
msg = "Failed trying to run soda test: \"#{@currentTestFile}\"!\n"
|
2743
|
-
|
2743
|
+
@rep.IncFailedTest()
|
2744
2744
|
@rep.ReportFailure(msg)
|
2745
2745
|
end
|
2746
2746
|
|
@@ -2753,149 +2753,141 @@ JSCode
|
|
2753
2753
|
|
2754
2754
|
###############################################################################
|
2755
2755
|
# RunAllSuites -- Method
|
2756
|
-
#
|
2756
|
+
# This function run a list of suite files as suites, not as tests.
|
2757
2757
|
#
|
2758
2758
|
# Input:
|
2759
|
-
#
|
2759
|
+
# suites: An array of Soda suite files to be ran.
|
2760
2760
|
#
|
2761
2761
|
# Output:
|
2762
|
-
#
|
2763
|
-
#
|
2764
|
-
###############################################################################
|
2765
|
-
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2794
|
-
|
2795
|
-
|
2796
|
-
|
2797
|
-
|
2798
|
-
|
2799
|
-
|
2800
|
-
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2762
|
+
# returns a hash with the results from the ran suites.
|
2763
|
+
#
|
2764
|
+
###############################################################################
|
2765
|
+
def RunAllSuites(suites)
|
2766
|
+
results = {}
|
2767
|
+
err = 0
|
2768
|
+
indent = " " * 2
|
2769
|
+
indent2 = "#{indent}" * 2
|
2770
|
+
indent3 = "#{indent}" * 4
|
2771
|
+
hostname = `hostname`
|
2772
|
+
hostname = hostname.chomp()
|
2773
|
+
|
2774
|
+
suites.each do |s|
|
2775
|
+
base_suite_name = File.basename(s)
|
2776
|
+
RestartGlobalTime()
|
2777
|
+
results[base_suite_name] = RunSuite(s)
|
2778
|
+
RestartGlobalTime()
|
2779
|
+
end
|
2780
|
+
|
2781
|
+
time = Time.now()
|
2782
|
+
time = "#{time.to_i}-#{time.usec}"
|
2783
|
+
suite_report = "#{@resultsDir}/#{hostname}-#{time}-suite.xml"
|
2784
|
+
fd = File.new(suite_report, "w+")
|
2785
|
+
fd.write("<data>\n")
|
2786
|
+
|
2787
|
+
RestartGlobalTime()
|
2788
|
+
|
2789
|
+
results.each do |k,v|
|
2790
|
+
fd.write("\t<suite>\n")
|
2791
|
+
fd.write("\t#{indent}<suitefile>#{k}</suitefile>\n")
|
2792
|
+
v.each do |testname, testhash|
|
2793
|
+
fd.write("\t#{indent2}<test>\n")
|
2794
|
+
fd.write("\t#{indent3}<testfile>#{testname}</testfile>\n")
|
2795
|
+
testhash.each do |tname, tvalue|
|
2796
|
+
if (tname == "result")
|
2797
|
+
err = -1 if (tvalue.to_i != 0)
|
2798
|
+
end
|
2799
|
+
new_name = "#{tname}"
|
2800
|
+
new_name = new_name.gsub(" ", "_")
|
2801
|
+
fd.write("\t#{indent3}<#{new_name}>#{tvalue}</#{new_name}>\n")
|
2802
|
+
end
|
2803
|
+
fd.write("\t#{indent2}</test>\n")
|
2804
|
+
end
|
2805
|
+
fd.write("\t</suite>\n")
|
2806
|
+
end
|
2807
|
+
fd.write("</data>\n")
|
2808
|
+
fd.close()
|
2809
|
+
|
2810
|
+
RestartGlobalTime()
|
2811
|
+
|
2812
|
+
return err
|
2813
|
+
end
|
2814
2814
|
|
2815
2815
|
###############################################################################
|
2816
2816
|
#
|
2817
2817
|
###############################################################################
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
|
2818
|
+
def RunSuite(suitefile)
|
2819
|
+
parser = nil
|
2820
|
+
doc = nil
|
2821
|
+
result = {}
|
2822
|
+
tests = []
|
2823
|
+
setup_test = nil
|
2824
|
+
cleanup_test = nil
|
2825
|
+
setup_results = 0
|
2826
|
+
|
2827
|
+
begin
|
2828
2828
|
parser = LibXML::XML::Parser.file(suitefile)
|
2829
2829
|
doc = parser.parse()
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
|
2859
|
-
|
2860
|
-
|
2861
|
-
|
2862
|
-
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
|
2868
|
-
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
|
2885
|
-
|
2886
|
-
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2890
|
-
|
2891
|
-
result[cleanup_test] = {'result' => -1}
|
2892
|
-
else
|
2893
|
-
result[cleanup_test] = {'result' => 0}
|
2894
|
-
end
|
2895
|
-
end
|
2896
|
-
|
2897
|
-
return result
|
2898
|
-
end
|
2830
|
+
doc = doc.root()
|
2831
|
+
|
2832
|
+
doc.each do |node|
|
2833
|
+
next if (node.name !~ /script/)
|
2834
|
+
attrs = node.attributes()
|
2835
|
+
attrs = attrs.to_h()
|
2836
|
+
|
2837
|
+
if (attrs.key?('file'))
|
2838
|
+
tests.push(attrs['file'])
|
2839
|
+
elsif (attrs.key?('fileset'))
|
2840
|
+
files = File.join(attrs['fileset'], "*.xml")
|
2841
|
+
files = Dir.glob(files)
|
2842
|
+
files.each do |f|
|
2843
|
+
tests.push(f)
|
2844
|
+
end
|
2845
|
+
end
|
2846
|
+
end
|
2847
|
+
rescue Exception => e
|
2848
|
+
print "ERROR: #{e.message}!\n"
|
2849
|
+
print e.backtrace.join("\n")
|
2850
|
+
result = nil
|
2851
|
+
ensure
|
2852
|
+
end
|
2853
|
+
|
2854
|
+
if (setup_test != nil)
|
2855
|
+
setup_result = run(setup_test, false, false)
|
2856
|
+
if (setup_result != 0)
|
2857
|
+
SodaUtils.PrintSoda("Failed calling setup test: "+
|
2858
|
+
"'#{setup_test}'!\n", SodaUtils::ERROR)
|
2859
|
+
result[setup_test] = {'result' => -1}
|
2860
|
+
setup_result = false
|
2861
|
+
else
|
2862
|
+
setup_result = true
|
2863
|
+
result[setup_test] = {'result' => 0}
|
2864
|
+
end
|
2865
|
+
else
|
2866
|
+
setup_result = true
|
2867
|
+
end
|
2868
|
+
|
2869
|
+
if (setup_result)
|
2870
|
+
tests.each do |test|
|
2871
|
+
result[test] = {}
|
2872
|
+
result[test]['result'] = run(test, false)
|
2873
|
+
result[test].merge!(@rep.GetRawResults)
|
2874
|
+
@rep.ZeroTestResults()
|
2875
|
+
end
|
2876
|
+
end
|
2877
|
+
|
2878
|
+
if (cleanup_test != nil)
|
2879
|
+
cleanup_result = run(cleanup_test, false, false)
|
2880
|
+
if (cleanup_result != 0)
|
2881
|
+
SodaUtils.PrintSoda("Failed calling cleanup test: "+
|
2882
|
+
"'#{cleanup_test}'!\n", SodaUtils::ERROR)
|
2883
|
+
result[cleanup_test] = {'result' => -1}
|
2884
|
+
else
|
2885
|
+
result[cleanup_test] = {'result' => 0}
|
2886
|
+
end
|
2887
|
+
end
|
2888
|
+
|
2889
|
+
return result
|
2890
|
+
end
|
2899
2891
|
|
2900
2892
|
###############################################################################
|
2901
2893
|
# GetCurrentBrowser -- Method
|
data/lib/sodainfo.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 7
|
10
|
+
version: 1.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Trampus Richmond
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-11 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|