1 /* Copyright 2016-present Samsung Electronics Co., Ltd. and other contributors
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 var testdriver = require('testdriver');
17 var console_wrapper = require('common_js/module/console');
19 function Runner(driver) {
20 process._exiting = false;
23 this.test = driver.currentTest();
24 this.finished = false;
25 if (driver.skipModule) {
26 this.skipModule = driver.skipModule;
27 this.skipModuleLength = this.skipModule.length;
29 this.skipModuleLength = 0;
31 if (driver.options.quiet == 'yes') {
32 this.console = console;
33 console = console_wrapper;
39 Runner.prototype.cleanup = function() {
40 if (this.driver.options.quiet == 'yes') {
41 console = this.console;
46 if (this.timer != null) {
47 clearTimeout(this.timer);
52 Runner.prototype.spin = function() {
54 process.nextTick(function() {
55 var timerOnlyAlive = !testdriver.isAliveExceptFor(that.timer);
57 timerOnlyAlive = !process._onNextTick();
70 Runner.prototype.checkSkipModule = function() {
71 for (var i = 0; i < this.skipModuleLength; i++) {
72 if (this.test['name'].indexOf(this.skipModule[i]) >= 0) {
81 Runner.prototype.run = function() {
82 var skip = this.test['skip'];
84 if ((skip.indexOf('all') >= 0) || (skip.indexOf(this.driver.os) >= 0)
85 || (skip.indexOf(this.driver.stability) >= 0)) {
91 if (this.skipModuleLength && this.checkSkipModule()) {
92 this.test.reason = 'exclude module';
98 if (this.test['timeout']) {
99 var timeout = this.test['timeout'];
102 this.timer = setTimeout(function () {
103 that.finish('timeout');
109 var source = this.driver.test();
112 if (this.test['expected-failure']) {
114 } else if (this.test['uncaught']) {
121 if (!this.finished) {
127 Runner.prototype.finish = function(status) {
131 this.finished = true;
133 this.driver.emitter.emit('nextTest', this.driver, status, this.test);
136 module.exports.Runner = Runner;