| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| <link rel="import" href="/base/base.html"> |
| <link rel="import" href="/base/unittest.html"> |
| <link rel="import" href="/base/unittest/test_runner.html"> |
| <link rel="import" href="/base/unittest/text_test_results.html"> |
| <script> |
| 'use strict'; |
| |
| (function() { |
| if (!tr.isHeadless) { |
| throw new Error('d8_tests.html only works in headless mode'); |
| } |
| |
| var results = new tr.b.unittest.TextTestResults(); |
| |
| function printSpacer() { |
| console.log('\n\n------------------------------------------------------' + |
| '----------------'); |
| } |
| function loadAndRunTests() { |
| var args = sys.argv.slice(1); |
| var suiteRelpathsToLoad = args.map(function(x) { |
| return '/' + x; |
| }); |
| |
| var loader = new tr.b.unittest.SuiteLoader(suiteRelpathsToLoad); |
| |
| var p = loader.allSuitesLoadedPromise; |
| |
| p = p.then( |
| function didAllSuitesLoad() { |
| var tests = loader.getAllTests().filter(function(testCase) { |
| if (testCase instanceof tr.b.unittest.PerfTestCase) |
| return false; |
| return true; |
| }); |
| if (tests.length === 0) { |
| printSpacer(); |
| console.log('FAILED: No tests to run.'); |
| console.log(err.stack); |
| quit(1); |
| } |
| var runner = new tr.b.unittest.TestRunner(results, tests); |
| return runner.beginRunning(); |
| }, |
| function suiteLoadingFailure(err) { |
| printSpacer(); |
| console.log('FAILED: A test suite failed to load.'); |
| console.log(err.stack); |
| quit(1); |
| }); |
| |
| p = p.then( |
| function didAllTestRun() { |
| if (results.numTestsThatFailed > 0) |
| quit(1); |
| else |
| quit(0); |
| }, |
| function testHarnessError(e) { |
| console.log('FAILED: A test harness error has ocurred.'); |
| console.log(e.stack); |
| quit(1); |
| }); |
| return p; |
| } |
| |
| loadAndRunTests(); |
| })(); |
| </script> |