soda 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/SodaSuite +24 -54
- data/bin/SodaSummaryCreator +18 -3
- data/lib/Soda.rb +149 -2
- data/lib/SodaReporter.rb +74 -0
- data/lib/SodaSuiteSummary.rb +1129 -0
- data/lib/SodaTestCheck.rb +1 -1
- metadata +5 -4
data/bin/SodaSuite
CHANGED
@@ -30,11 +30,13 @@
|
|
30
30
|
###############################################################################
|
31
31
|
# Needed Ruby libs:
|
32
32
|
###############################################################################
|
33
|
+
require 'rubygems'
|
33
34
|
require 'Soda'
|
34
35
|
require 'getoptlong'
|
35
36
|
require 'libxml'
|
36
37
|
require 'watir'
|
37
38
|
require 'SodaReportSummery'
|
39
|
+
require 'SodaSuiteSummary'
|
38
40
|
require 'pp'
|
39
41
|
|
40
42
|
###############################################################################
|
@@ -119,46 +121,15 @@ class SodaSuite
|
|
119
121
|
# None.
|
120
122
|
#
|
121
123
|
###############################################################################
|
122
|
-
def
|
124
|
+
def ExecuteTestSuites(suites)
|
123
125
|
soda = nil
|
124
|
-
master_result = 0
|
125
126
|
result = nil
|
126
|
-
|
127
|
-
soda = Soda::Soda.new(@SodaParams)
|
128
|
-
|
129
|
-
if (reruntest != nil)
|
130
|
-
SodaUtils.PrintSoda("Running rerun test setup script: "+
|
131
|
-
"'#{reruntest}'.\n")
|
132
|
-
soda.run(reruntest)
|
133
|
-
end
|
134
|
-
|
135
|
-
suite.each do |test|
|
136
|
-
result = soda.run(test, rerun)
|
137
|
-
if (result == -1)
|
138
|
-
SodaUtils.PrintSoda("Failed executing test file: #{test}!\n",
|
139
|
-
SodaUtils::ERROR)
|
140
|
-
master_result = -1
|
141
|
-
|
142
|
-
begin
|
143
|
-
soda.browser.close()
|
144
|
-
rescue Exception => e
|
145
|
-
print "Exception: #{e.message}\n"
|
146
|
-
ensure
|
147
|
-
end
|
148
|
-
soda = Soda::Soda.new(@SodaParams)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
begin
|
153
|
-
soda.browser.close()
|
154
|
-
rescue Exception => e
|
155
|
-
print "Exception: #{e.message}\n"
|
156
|
-
ensure
|
157
|
-
end
|
158
127
|
|
159
|
-
soda =
|
160
|
-
|
161
|
-
|
128
|
+
soda = Soda::Soda.new(@SodaParams)
|
129
|
+
result = soda.RunAllSuites(suites)
|
130
|
+
|
131
|
+
return result
|
132
|
+
end
|
162
133
|
|
163
134
|
###############################################################################
|
164
135
|
# Execute -- Medhod
|
@@ -621,6 +592,11 @@ def Main
|
|
621
592
|
PrintHelp()
|
622
593
|
end
|
623
594
|
|
595
|
+
if (params['suites'].length > 0 && params['resultsdir'] == nil)
|
596
|
+
SodaUtils.PrintSoda("Missing argument --resultsdir!\n")
|
597
|
+
PrintHelp()
|
598
|
+
end
|
599
|
+
|
624
600
|
if (params['debug'])
|
625
601
|
SodaUtils.PrintSoda("SodaSuite Params:\n")
|
626
602
|
params.each do |k, v|
|
@@ -649,12 +625,7 @@ def Main
|
|
649
625
|
|
650
626
|
if (params['suites'].length > 0)
|
651
627
|
sweet = SodaSuite.new(params)
|
652
|
-
params['suites']
|
653
|
-
result = sweet.ExecuteTestSuite(swt)
|
654
|
-
if (result != 0)
|
655
|
-
master_result = -1
|
656
|
-
end
|
657
|
-
end
|
628
|
+
result = sweet.ExecuteTestSuites(params['suites'])
|
658
629
|
end
|
659
630
|
|
660
631
|
if (params['test_files'].length > 0)
|
@@ -672,20 +643,19 @@ def Main
|
|
672
643
|
end
|
673
644
|
end
|
674
645
|
|
675
|
-
# see if we should rerun failed tests #
|
676
|
-
if (rerun_failed_test && failed_tests.length > 0)
|
677
|
-
SodaUtils.PrintSoda("Rerunning failed tests.\n")
|
678
|
-
sweet.ExecuteTestSuite(failed_tests, true, rerun_test_script)
|
679
|
-
SodaUtils.PrintSoda("Finished rerunning failed tests.\n")
|
680
|
-
end
|
681
|
-
|
682
646
|
if (params['resultsdir'] != nil)
|
683
647
|
begin
|
684
|
-
|
685
|
-
params['
|
648
|
+
if (params['suites'].length > 0)
|
649
|
+
summary = SodaSuiteSummary.new(params['resultsdir'],
|
650
|
+
params['summaryfile'], true)
|
651
|
+
else
|
652
|
+
summery = SodaReportSummery.new(params['resultsdir'],
|
653
|
+
params['summaryfile'], true)
|
654
|
+
end
|
686
655
|
rescue Exception => e
|
687
|
-
print "Error: calling: SodaReportSummery
|
688
|
-
print
|
656
|
+
print "Error: calling: SodaReportSummery: #{e.message}\n"
|
657
|
+
print e.backtrace.join("\n")
|
658
|
+
print "\n\n"
|
689
659
|
exit(-1)
|
690
660
|
ensure
|
691
661
|
end
|
data/bin/SodaSummaryCreator
CHANGED
@@ -28,6 +28,7 @@
|
|
28
28
|
|
29
29
|
require 'rubygems'
|
30
30
|
require 'SodaReportSummery'
|
31
|
+
require 'SodaSuiteSummary'
|
31
32
|
require 'getoptlong'
|
32
33
|
|
33
34
|
###############################################################################
|
@@ -51,6 +52,10 @@ Required Flags:
|
|
51
52
|
--reportdir: This flag tells #{$0} where to find the Soda log files.
|
52
53
|
|
53
54
|
Optional Flags:
|
55
|
+
--usesuites: This flag say that the summary to be generated is for reports
|
56
|
+
that were created by SodaSuite using the --suite flag and not the --test
|
57
|
+
flag.
|
58
|
+
|
54
59
|
--help: Prints this message and exits.
|
55
60
|
|
56
61
|
HLP
|
@@ -77,10 +82,12 @@ def Main()
|
|
77
82
|
reportdir = nil
|
78
83
|
summary_file = nil
|
79
84
|
summary_obj = nil
|
85
|
+
use_suites = false
|
80
86
|
|
81
87
|
opts = GetoptLong.new(
|
82
88
|
['--reportdir', '-r', GetoptLong::REQUIRED_ARGUMENT],
|
83
|
-
['--help', '-h', GetoptLong::OPTIONAL_ARGUMENT]
|
89
|
+
['--help', '-h', GetoptLong::OPTIONAL_ARGUMENT],
|
90
|
+
['--usesuites', '-s', GetoptLong::OPTIONAL_ARGUMENT]
|
84
91
|
)
|
85
92
|
|
86
93
|
opts.quiet = true
|
@@ -88,6 +95,8 @@ def Main()
|
|
88
95
|
case (opt)
|
89
96
|
when "--reportdir"
|
90
97
|
reportdir = arg
|
98
|
+
when "--usesuites"
|
99
|
+
use_suites = true
|
91
100
|
when "--help"
|
92
101
|
PrintHelp()
|
93
102
|
exit(0)
|
@@ -103,11 +112,17 @@ def Main()
|
|
103
112
|
summary_file = "#{reportdir}/summary.html"
|
104
113
|
begin
|
105
114
|
print "(*)Creating summary report...\n"
|
106
|
-
|
115
|
+
if (use_suites)
|
116
|
+
summary_obj = SodaSuiteSummary.new(reportdir, summary_file, true)
|
117
|
+
else
|
118
|
+
summary_obj = SodaReportSummery.new(reportdir, summary_file, true)
|
119
|
+
end
|
107
120
|
print "(*)Finished creating report.\n"
|
108
121
|
print "(*)Summary File: #{summary_file}\n"
|
109
122
|
rescue Exception => e
|
110
|
-
print "(!)Error: #{e.message}!\n
|
123
|
+
print "(!)Error: #{e.message}!\n"
|
124
|
+
print e.backtrace.join("\n")
|
125
|
+
print "\n\n"
|
111
126
|
exit(2)
|
112
127
|
ensure
|
113
128
|
end
|
data/lib/Soda.rb
CHANGED
@@ -57,6 +57,7 @@ require "fields/FileField"
|
|
57
57
|
require "fields/LiField"
|
58
58
|
require 'thread'
|
59
59
|
require 'date'
|
60
|
+
require 'pp'
|
60
61
|
|
61
62
|
###############################################################################
|
62
63
|
# Soda -- Class
|
@@ -2676,7 +2677,7 @@ JSCode
|
|
2676
2677
|
# returns a SodaReport object.
|
2677
2678
|
#
|
2678
2679
|
###############################################################################
|
2679
|
-
def run(file, rerun = false)
|
2680
|
+
def run(file, rerun = false, genhtml = true)
|
2680
2681
|
result = 0
|
2681
2682
|
master_result = 0
|
2682
2683
|
thread_soda = nil
|
@@ -2743,11 +2744,157 @@ JSCode
|
|
2743
2744
|
|
2744
2745
|
@rep.SodaPrintCurrentReport()
|
2745
2746
|
@rep.EndTestReport()
|
2746
|
-
@rep.ReportHTML()
|
2747
|
+
@rep.ReportHTML() if (genhtml)
|
2747
2748
|
|
2748
2749
|
return master_result
|
2749
2750
|
end
|
2750
2751
|
|
2752
|
+
###############################################################################
|
2753
|
+
# RunAllSuites -- Method
|
2754
|
+
# This function run a list of suite files as suites, not as tests.
|
2755
|
+
#
|
2756
|
+
# Input:
|
2757
|
+
# suites: An array of Soda suite files to be ran.
|
2758
|
+
#
|
2759
|
+
# Output:
|
2760
|
+
# returns a hash with the results from the ran suites.
|
2761
|
+
#
|
2762
|
+
###############################################################################
|
2763
|
+
def RunAllSuites(suites)
|
2764
|
+
results = {}
|
2765
|
+
err = 0
|
2766
|
+
indent = " " * 2
|
2767
|
+
indent2 = "#{indent}" * 2
|
2768
|
+
indent3 = "#{indent}" * 4
|
2769
|
+
hostname = `hostname`
|
2770
|
+
hostname = hostname.chomp()
|
2771
|
+
|
2772
|
+
suites.each do |s|
|
2773
|
+
base_suite_name = File.basename(s)
|
2774
|
+
RestartGlobalTime()
|
2775
|
+
results[base_suite_name] = RunSuite(s)
|
2776
|
+
RestartGlobalTime()
|
2777
|
+
end
|
2778
|
+
|
2779
|
+
time = Time.now()
|
2780
|
+
time = "#{time.to_i}-#{time.usec}"
|
2781
|
+
suite_report = "#{@resultsDir}/#{hostname}-#{time}-suite.xml"
|
2782
|
+
fd = File.new(suite_report, "w+")
|
2783
|
+
fd.write("<data>\n")
|
2784
|
+
|
2785
|
+
RestartGlobalTime()
|
2786
|
+
|
2787
|
+
results.each do |k,v|
|
2788
|
+
fd.write("\t<suite>\n")
|
2789
|
+
fd.write("\t#{indent}<suitefile>#{k}</suitefile>\n")
|
2790
|
+
v.each do |testname, testhash|
|
2791
|
+
fd.write("\t#{indent2}<test>\n")
|
2792
|
+
fd.write("\t#{indent3}<testfile>#{testname}</testfile>\n")
|
2793
|
+
testhash.each do |tname, tvalue|
|
2794
|
+
if (tname == "result")
|
2795
|
+
err = -1 if (tvalue.to_i != 0)
|
2796
|
+
end
|
2797
|
+
new_name = "#{tname}"
|
2798
|
+
new_name = new_name.gsub(" ", "_")
|
2799
|
+
fd.write("\t#{indent3}<#{new_name}>#{tvalue}</#{new_name}>\n")
|
2800
|
+
end
|
2801
|
+
fd.write("\t#{indent2}</test>\n")
|
2802
|
+
end
|
2803
|
+
fd.write("\t</suite>\n")
|
2804
|
+
end
|
2805
|
+
fd.write("</data>\n")
|
2806
|
+
fd.close()
|
2807
|
+
|
2808
|
+
RestartGlobalTime()
|
2809
|
+
|
2810
|
+
return err
|
2811
|
+
end
|
2812
|
+
|
2813
|
+
###############################################################################
|
2814
|
+
#
|
2815
|
+
###############################################################################
|
2816
|
+
def RunSuite(suitefile)
|
2817
|
+
parser = nil
|
2818
|
+
doc = nil
|
2819
|
+
result = {}
|
2820
|
+
tests = []
|
2821
|
+
setup_test = nil
|
2822
|
+
cleanup_test = nil
|
2823
|
+
setup_results = 0
|
2824
|
+
|
2825
|
+
begin
|
2826
|
+
parser = LibXML::XML::Parser.file(suitefile)
|
2827
|
+
doc = parser.parse()
|
2828
|
+
doc = doc.root()
|
2829
|
+
|
2830
|
+
doc.each do |node|
|
2831
|
+
next if (node.name !~ /script/)
|
2832
|
+
attrs = node.attributes()
|
2833
|
+
attrs = attrs.to_h()
|
2834
|
+
|
2835
|
+
if (attrs.key?('file'))
|
2836
|
+
base_name = File.basename(attrs['file'])
|
2837
|
+
if (base_name =~ /^setup/)
|
2838
|
+
setup_test = attrs['file']
|
2839
|
+
elsif (base_name =~ /^cleanup/)
|
2840
|
+
cleanup_test = attrs['file']
|
2841
|
+
else
|
2842
|
+
tests.push(attrs['file'])
|
2843
|
+
end
|
2844
|
+
elsif (attrs.key?('fileset'))
|
2845
|
+
files = File.join(attrs['fileset'], "*.xml")
|
2846
|
+
files = Dir.glob(files)
|
2847
|
+
files.each do |f|
|
2848
|
+
tests.push(f)
|
2849
|
+
end
|
2850
|
+
end
|
2851
|
+
end
|
2852
|
+
rescue Exception => e
|
2853
|
+
print "ERROR: #{e.message}!\n"
|
2854
|
+
print e.backtrace.join("\n")
|
2855
|
+
result = nil
|
2856
|
+
ensure
|
2857
|
+
end
|
2858
|
+
|
2859
|
+
|
2860
|
+
if (setup_test != nil)
|
2861
|
+
setup_result = run(setup_test, false, false)
|
2862
|
+
if (setup_result != 0)
|
2863
|
+
SodaUtils.PrintSoda("Failed calling setup test: "+
|
2864
|
+
"'#{setup_test}'!\n", SodaUtils::ERROR)
|
2865
|
+
result[setup_test] = {'result' => -1}
|
2866
|
+
setup_result = false
|
2867
|
+
else
|
2868
|
+
setup_result = true
|
2869
|
+
result[setup_test] = {'result' => 0}
|
2870
|
+
end
|
2871
|
+
else
|
2872
|
+
setup_result = true
|
2873
|
+
end
|
2874
|
+
|
2875
|
+
if (setup_result)
|
2876
|
+
tests.each do |test|
|
2877
|
+
result[test] = {}
|
2878
|
+
result[test]['result'] = run(test, false)
|
2879
|
+
result[test].merge!(@rep.GetRawResults)
|
2880
|
+
@rep.ZeroTestResults()
|
2881
|
+
end
|
2882
|
+
end
|
2883
|
+
|
2884
|
+
if (cleanup_test != nil)
|
2885
|
+
cleanup_result = run(cleanup_test, false, false)
|
2886
|
+
if (cleanup_result != 0)
|
2887
|
+
SodaUtils.PrintSoda("Failed calling cleanup test: "+
|
2888
|
+
"'#{cleanup_test}'!\n", SodaUtils::ERROR)
|
2889
|
+
result[cleanup_test] = {'result' => -1}
|
2890
|
+
else
|
2891
|
+
result[cleanup_test] = {'result' => 0}
|
2892
|
+
end
|
2893
|
+
end
|
2894
|
+
|
2895
|
+
return result
|
2896
|
+
end
|
2897
|
+
|
2751
2898
|
###############################################################################
|
2752
2899
|
# GetCurrentBrowser -- Method
|
2753
2900
|
# This method get the current Watir browser object.
|
data/lib/SodaReporter.rb
CHANGED
@@ -45,12 +45,17 @@ require 'SodaLogReporter'
|
|
45
45
|
# simple reporter class that tracks asserts, exceptions, and log messages
|
46
46
|
###############################################################################
|
47
47
|
class SodaReporter
|
48
|
+
attr_accessor :asserts_count, :js_error_count, :css_error_count,
|
49
|
+
:assertFails_count, :exception_count, :test_skip_count,
|
50
|
+
:test_blocked_count, :test_watchdog_count
|
48
51
|
|
49
52
|
def initialize(testfile, savehtml = false, resultsdir = nil, debug = 0,
|
50
53
|
callback = nil, rerun = false)
|
51
54
|
@sodatest_file = testfile
|
52
55
|
@saveHtmlFiles = savehtml
|
53
56
|
@debug = debug
|
57
|
+
@start_time = nil
|
58
|
+
@end_time = nil
|
54
59
|
@js_error_count = 0
|
55
60
|
@css_error_count = 0
|
56
61
|
@asserts_count = 0
|
@@ -116,8 +121,76 @@ class SodaReporter
|
|
116
121
|
log("[New Test]\n")
|
117
122
|
log("Starting soda test: #{@sodatest_file}\n")
|
118
123
|
log("Saving HTML files => #{@saveHtmlFiles.to_s()}.\n")
|
124
|
+
@start_time = Time.now().strftime("%m/%d/%Y-%H:%M:%S")
|
119
125
|
end
|
120
126
|
|
127
|
+
###############################################################################
|
128
|
+
# GetRawResults -- Method
|
129
|
+
# This method gets test results data.
|
130
|
+
#
|
131
|
+
# Input:
|
132
|
+
# None.
|
133
|
+
#
|
134
|
+
# Output:
|
135
|
+
# returns a hash of test report data.
|
136
|
+
#
|
137
|
+
###############################################################################
|
138
|
+
def GetRawResults()
|
139
|
+
|
140
|
+
@end_time = Time.now().strftime("%m/%d/%Y-%H:%M:%S") if (@end_time == nil)
|
141
|
+
start = DateTime.strptime("#{@start_time}",
|
142
|
+
"%m/%d/%Y-%H:%M:%S")
|
143
|
+
stop = DateTime.strptime("#{@end_time}",
|
144
|
+
"%m/%d/%Y-%H:%M:%S")
|
145
|
+
total_time = (stop - start)
|
146
|
+
|
147
|
+
results = {
|
148
|
+
'Test Assert Count' => @asserts_count,
|
149
|
+
'Test JavaScript Error Count' => @js_error_count,
|
150
|
+
'Test CSS Error Count' => @css_error_count,
|
151
|
+
'Test Assert Failures' => @assertFails_count,
|
152
|
+
'Test Exceptions' => @exception_count,
|
153
|
+
'Test Skip Count' => @test_skip_count,
|
154
|
+
'Test Blocked Count' => @test_blocked_count,
|
155
|
+
'Test WatchDog Count' => @test_watchdog_count,
|
156
|
+
'Test Warning Count' => @test_warning_count,
|
157
|
+
'Test Event Count' => @total,
|
158
|
+
'Test Start Time' => @start_time,
|
159
|
+
'Test Stop Time' => @end_time
|
160
|
+
}
|
161
|
+
|
162
|
+
return results
|
163
|
+
end
|
164
|
+
|
165
|
+
###############################################################################
|
166
|
+
# ZeroTestResults -- Method
|
167
|
+
# This method zero's out needed reported values for a test when running
|
168
|
+
# a suite. Really this is only needed until SugarCRM internally starts
|
169
|
+
# using real suites and I can go back to undo the hack's put in place to
|
170
|
+
# do suite reporting when using the --test option to run suites.
|
171
|
+
#
|
172
|
+
# Input:
|
173
|
+
# None.
|
174
|
+
#
|
175
|
+
# Output:
|
176
|
+
# None.
|
177
|
+
#
|
178
|
+
###############################################################################
|
179
|
+
def ZeroTestResults()
|
180
|
+
@asserts_count = 0
|
181
|
+
@js_error_count = 0
|
182
|
+
@css_error_count = 0
|
183
|
+
@assertFails_count = 0
|
184
|
+
@exception_count = 0
|
185
|
+
@test_skip_count = 0
|
186
|
+
@test_blocked_count = 0
|
187
|
+
@test_watchdog_count = 0
|
188
|
+
@test_warning_count = 0
|
189
|
+
@total = 0
|
190
|
+
@start_time = nil
|
191
|
+
@end_time = nil
|
192
|
+
end
|
193
|
+
|
121
194
|
###############################################################################
|
122
195
|
# GetResultDir -- Method
|
123
196
|
# This method returns the current result dir.
|
@@ -398,6 +471,7 @@ class SodaReporter
|
|
398
471
|
NFSRenameHack(@log_filename, tmp_logfile)
|
399
472
|
|
400
473
|
@log_filename = tmp_logfile
|
474
|
+
@end_time = Time.now().strftime("%m/%d/%Y-%H:%M:%S")
|
401
475
|
end
|
402
476
|
|
403
477
|
###############################################################################
|