2018-02-16 14:02:18 -05:00
|
|
|
/**
|
|
|
|
* Environment-specific runner initialization
|
|
|
|
*
|
2022-05-03 14:14:29 -04:00
|
|
|
* Copyright (C) 2014-2022 Ryan Specialty Group, LLC.
|
2018-02-16 14:02:18 -05:00
|
|
|
*
|
|
|
|
* This file is part of TAME.
|
|
|
|
*
|
|
|
|
* TAME is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const yaml_reader = require( 'js-yaml' );
|
|
|
|
|
|
|
|
const {
|
|
|
|
TestCase,
|
|
|
|
TestRunner,
|
2018-03-05 16:22:13 -05:00
|
|
|
AsyncTestRunner,
|
2018-02-16 14:02:18 -05:00
|
|
|
|
|
|
|
reader: {
|
|
|
|
ConstResolver,
|
|
|
|
DateResolver,
|
|
|
|
YamlTestReader
|
|
|
|
},
|
|
|
|
|
|
|
|
reporter: {
|
2018-02-23 14:15:09 -05:00
|
|
|
ConsoleTestReporter,
|
|
|
|
HtmlConsoleOutput,
|
2018-02-16 14:02:18 -05:00
|
|
|
},
|
|
|
|
} = require( '../src' );
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
2018-03-05 16:22:13 -05:00
|
|
|
console: ( program, stdout ) => module.exports.common(
|
|
|
|
program,
|
|
|
|
stdout,
|
|
|
|
TestRunner(
|
|
|
|
ConsoleTestReporter( stdout ),
|
|
|
|
program
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
browser: ( program, stdout ) => module.exports.common(
|
|
|
|
program,
|
|
|
|
stdout,
|
|
|
|
AsyncTestRunner(
|
|
|
|
ConsoleTestReporter.use( HtmlConsoleOutput )( stdout ),
|
2018-02-16 14:02:18 -05:00
|
|
|
program
|
2018-03-05 16:22:13 -05:00
|
|
|
)
|
|
|
|
),
|
2018-02-16 14:02:18 -05:00
|
|
|
|
2018-03-05 16:22:13 -05:00
|
|
|
common: ( program, stdout, runner ) =>
|
|
|
|
{
|
2018-02-16 14:02:18 -05:00
|
|
|
const reader = YamlTestReader
|
|
|
|
.use( DateResolver )
|
|
|
|
.use( ConstResolver( program ) )
|
|
|
|
( yaml_reader, TestCase );
|
|
|
|
|
2018-02-16 15:44:09 -05:00
|
|
|
// XXX: work around issue with consts not being initialized ahead of
|
|
|
|
// time (initialized during actual rating...!)
|
2018-03-06 14:16:32 -05:00
|
|
|
program.rater( {}, false );
|
2018-02-16 15:44:09 -05:00
|
|
|
|
2018-02-16 15:25:36 -05:00
|
|
|
return yaml => new Promise( ( resolve, reject ) =>
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const cases = reader.loadCases( yaml );
|
|
|
|
|
|
|
|
resolve( runner.runTests( cases ) );
|
|
|
|
}
|
|
|
|
catch ( e )
|
|
|
|
{
|
|
|
|
reject( e );
|
|
|
|
}
|
|
|
|
} );
|
2018-02-16 14:02:18 -05:00
|
|
|
},
|
|
|
|
};
|