Changeset 7983
- Timestamp:
- 10/21/07 01:47:30 (1 year ago)
- Files:
-
- spinoffs/prototype/trunk/CHANGELOG (modified) (1 diff)
- spinoffs/prototype/trunk/test/lib/jstest.rb (modified) (2 diffs)
- spinoffs/prototype/trunk/test/lib/unittest.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/prototype/trunk/CHANGELOG
r7960 r7983 1 1 *SVN* 2 3 * Minor cosmetic changes to the display of unit tests in terminal. [Tobie Langel] 2 4 3 5 * Make submitting forms work in Opera < 9.1. Closes #9917, #9463, #8260. [kangax] spinoffs/prototype/trunk/test/lib/jstest.rb
r7265 r7983 204 204 @queue = Queue.new 205 205 206 result = []207 208 206 @server = WEBrick::HTTPServer.new(:Port => 4711) # TODO: make port configurable 209 207 @server.mount_proc("/results") do |req, res| 210 @queue.push(req.query['result']) 208 @queue.push({ 209 :tests => req.query['tests'].to_i, 210 :assertions => req.query['assertions'].to_i, 211 :failures => req.query['failures'].to_i, 212 :errors => req.query['errors'].to_i 213 }) 211 214 res.body = "OK" 212 215 end … … 226 229 trap("INT") { @server.shutdown } 227 230 t = Thread.new { @server.start } 228 231 229 232 # run all combinations of browsers and tests 230 233 @browsers.each do |browser| 231 234 if browser.supported? 235 t0 = Time.now 236 results = {:tests => 0, :assertions => 0, :failures => 0, :errors => 0} 237 errors = [] 238 failures = [] 232 239 browser.setup 240 puts "\nStarted tests in #{browser}" 233 241 @tests.each do |test| 234 242 browser.visit("http://localhost:4711#{test}?resultsURL=http://localhost:4711/results&t=" + ("%.6f" % Time.now.to_f)) 243 235 244 result = @queue.pop 236 puts "#{test} on #{browser}: #{result}" 245 result.each { |k, v| results[k] += v } 246 value = "." 247 248 if result[:failures] > 0 249 value = "F" 250 failures.push(test) 251 end 252 253 if result[:errors] > 0 254 value = "E" 255 errors.push(test) 256 end 257 258 print value 237 259 end 260 261 puts "\nFinished in #{(Time.now - t0).round.to_s} seconds." 262 puts " Failures: #{failures.join(', ')}" unless failures.empty? 263 puts " Errors: #{errors.join(', ')}" unless errors.empty? 264 puts "#{results[:tests]} tests, #{results[:assertions]} assertions, #{results[:failures]} failures, #{results[:errors]} errors" 238 265 browser.teardown 239 266 else 240 puts " Skipping #{browser}, not supported on this OS"267 puts "\nSkipping #{browser}, not supported on this OS" 241 268 end 242 269 end spinoffs/prototype/trunk/test/lib/unittest.js
r7298 r7983 178 178 // "SUCCESS" if there was neither 179 179 getResult: function() { 180 var hasFailure = false;181 for(var i=0;i<this.tests.length;i++) {182 if (this.tests[i].errors > 0) {183 return "ERROR";184 }185 if (this.tests[i].failures > 0) {186 hasFailure = true;187 }188 }189 if (hasFailure) {190 re turn "FAILURE";191 } else {192 return "SUCCESS";193 }194 },180 var results = { 181 tests: this.tests.length, 182 assertions: 0, 183 failures: 0, 184 errors: 0 185 }; 186 187 return this.tests.inject(results, function(results, test) { 188 results.assertions += test.assertions; 189 results.failures += test.failures; 190 results.errors += test.errors; 191 return results; 192 }); 193 }, 194 195 195 postResults: function() { 196 196 if (this.options.resultsURL) { 197 197 new Ajax.Request(this.options.resultsURL, 198 { method: 'get', parameters: 'result=' +this.getResult(), asynchronous: false });198 { method: 'get', parameters: this.getResult(), asynchronous: false }); 199 199 } 200 200 }, … … 225 225 } 226 226 }, 227 227 228 summary: function() { 228 var assertions = 0; 229 var failures = 0; 230 var errors = 0; 231 var messages = []; 232 for(var i=0;i<this.tests.length;i++) { 233 assertions += this.tests[i].assertions; 234 failures += this.tests[i].failures; 235 errors += this.tests[i].errors; 236 } 237 return ( 238 this.tests.length + " tests, " + 239 assertions + " assertions, " + 240 failures + " failures, " + 241 errors + " errors"); 229 return '#{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors' 230 .interpolate(this.getResult()); 242 231 } 243 232 }