Run tests from a Codeception config file.
@param $configPath
@return bool|mixed
@throws \Exception
347973
protected function runConfigFile($configPath)
    {
        $this->phpci->logExecOutput(false);

        $codecept = $this->phpci->findBinary('codecept');

        if (!$codecept) {
            $this->phpci->logFailure(Lang::get('could_not_find', 'codecept'));

            return false;
        }

        $cmd = 'cd "%s" && ' . $codecept . ' run -c "%s" --xml ' . $this->args;

        if (IS_WIN) {
            $cmd = 'cd /d "%s" && ' . $codecept . ' run -c "%s" --xml ' . $this->args;
        }

        $configPath = $this->phpci->buildPath . $configPath;
        $success = $this->phpci->executeCommand($cmd, $this->phpci->buildPath, $configPath);

        $this->phpci->log(
            'Codeception XML path: '. $this->phpci->buildPath . $this->path . 'report.xml',
            Loglevel::DEBUG
        );

        $xml = file_get_contents($this->phpci->buildPath . $this->path . 'report.xml', false);
        $parser = new Parser($this->phpci, $xml);
        $output = $parser->parse();

        $meta = array(
            'tests'     => $parser->getTotalTests(),
            'timetaken' => $parser->getTotalTimeTaken(),
            'failures'  => $parser->getTotalFailures()
        );

        $this->build->storeMeta('codeception-meta', $meta);
        $this->build->storeMeta('codeception-data', $output);
        $this->build->storeMeta('codeception-errors', $parser->getTotalFailures());
        $this->phpci->logExecOutput(true);

        return $success;
    }
233337
public function init(string $configPath): self
    {
        defined('INTERVAL') or define('INTERVAL', 10000);
        defined('SAW_DIR') or define('SAW_DIR', __DIR__);
        $config = array_merge(
            require __DIR__ . '/../config/saw.php',
            require $configPath
        );
        // todo include config
        foreach (['saw', 'factory', 'daemon', 'sockets', 'application', 'controller'] as $check) {
            if (!isset($config[$check]) || !is_array($config[$check])) {
                $config[$check] = [];
            }
        }
        if (isset($config['saw']['debug'])) {
            self::$debug = (bool)$config['saw']['debug'];
        }

        $initScript = __DIR__ . '/../bin/cli.php';
        if (!isset($config['controller_starter'])) {
            $config['controller_starter'] = <<<CMD
-r "require_once '{$initScript}';
\Maestroprog\Saw\Saw::instance()
    ->init('{$configPath}')
    ->instanceController()
    ->start();"
CMD;
        }
        if (!isset($config['worker_starter'])) {
            $config['worker_starter'] = <<<CMD
-r "require_once '{$initScript}';
\Maestroprog\Saw\Saw::instance()
    ->init('{$configPath}')
    ->instanceWorker()
    ->start();"
CMD;
        }

        $this->container = Container::instance();
        $this->container->register($this->sawContainer = new SawContainer(
            $this->config = $config,
            $this->daemonConfig = new DaemonConfig($config['daemon'], $configPath),
            $this->config = new Configurator($config['sockets']),
            $this->controllerConfig = new ControllerConfig($config['controller']),
            SawEnv::web()
        ));
        $this->container->register(new MemoryContainer());

        $this->applicationLoader = new ApplicationLoader(
            new ApplicationConfig($config['application']),
            new ApplicationFactory($this->container)
        );

        if (!self::$debug) {
            set_exception_handler(function (\Throwable $exception) {
                if ($exception instanceof \Exception) {
                    switch ($exception->getCode()) {
                        case self::ERROR_WRONG_CONFIG:
                            echo $exception->getMessage();
                            exit($exception->getCode());
                    }
                }
            });
        }

        /*$compiler = new ContainerCompiler($this->container);
        $compiler->compile('build/container.php');*/

        return $this;
    }
888117
public function load($config) {
		if ($this->configsDir === null) {
			new Exceptions\ConfiguratorError('Directory of configuration files did not been set');
		}
		
		$file = $this->configsDir->getFile($config);
		
		$this->addConfigReader($this->initReader($file));
		
		return $this;
	}
1098228
function loadConfig(configPath) {
	return new Promise((resolve, reject) => {
		configPath = resolveConfigPath(configPath);
		let config;
		try {
			config = loadLocalConfigUnmodified(configPath);
			if (!config) {
				config = loadLocalConfigWithJs(configPath);
			}
			if (!config) {
				config = loadLocalConfigWithJson(configPath);
			}
			if (program.config && !config) {
				return reject(new Error(`The config file "${configPath}" could not be loaded`));
			}
		} catch (error) {
			return reject(
				new Error(`There was a problem loading "${configPath}":\n${error.stack}`)
			);
		}

		// Allow loaded configs to return a promise
		Promise.resolve(config).then(config => {
			resolve(defaultConfig(config || {}));
		});
	});
}
1031221
public function httpExceptionResponse($configData)
    {
        $components = $this->builder->components();
        
        return new Processors\HTTP\Response\Exception(
            $components->debug(),
            $components->http(),
            $components->template(),
            $configData
        );
    }
255490
public function load(string $path = '')
    {
        if ($path) {
            $testFileLoader = new TestFileLoader($this->options);
            $this->files = array_merge(
                $this->files,
                $testFileLoader->loadPath($path)
            );
        } elseif (
            isset($this->options->parallelSuite)
            && $this->options->parallelSuite
        ) {
            $this->suitesName = $this->configuration->getSuitesName();
        } elseif ($this->configuration->hasSuites()) {
            if (!empty($this->options->testsuite)) {
                $suites = [];
                foreach ($this->options->testsuite as $testsuite) {
                    $suites = array_merge($suites, $this->configuration->getSuiteByName($testsuite));
                }
            } else {
                $suites = $this->configuration->getSuites();
            }

            foreach ($suites as $suite) {
                foreach ($suite as $suitePath) {
                    $testFileLoader = new TestFileLoader($this->options);
                    $this->files = array_merge(
                        $this->files,
                        $testFileLoader->loadSuitePath($suitePath)
                    );
                }
            }
        }

        if (!$this->files && !\is_array($this->suitesName)) {
            throw new \RuntimeException('No path or configuration provided (tests must end with Test.php)');
        }

        $this->files = array_unique($this->files); // remove duplicates

        $this->initSuites();
    }
705756
public function run(Config $configuration)
    {
        $this->config = $configuration;
        $this->config->set('base', str_replace('app.php', '', $_SERVER['SCRIPT_NAME']));
        try {
            $request = $this->getRequest();
            if (!$this->config->get('routes')) {
                throw new Exception404( "No routes", 1 );
            } else {
                list($controller_name, $action_name, $parameters) = $this->findRoute($request);
            }

            $controller = new $controller_name();
            $controller->$action_name( $parameters );
        } catch ( Exception404 $e ) {
            $e->displayMessage();
        }
    }
1050200
public function init($config = [])
    {
        $type  = isset($config['type']) ? $config['type'] : 'File';
        $class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);

        $this->config = $config;

        unset($config['type']);

        if (class_exists($class)) {
            $this->driver = new $class($config);
        } else {
            throw new Exception('class not exists:' . $class, $class);
        }

        return $this;
    }
205576
protected function _readConfigCore($path = null, $configPattern = null) {
		if (empty($path) || empty($configPattern)) {
			return false;
		}

		$oFile = new File($path . 'Config' . DS . 'core.php');
		if (!$oFile->exists()) {
			return false;
		}

		$contents = $oFile->read();
		if (!preg_match($configPattern, $contents, $match) || (count($match) < 1)) {
			return false;
		}

		return $match[1];
	}
65249
public function loadConfig($configFile = 'config.user.php', $configPath = 'app/config') {
        $completePath = ROOT . DS . $configPath . DS . $configFile;

        if (!file_exists($completePath)) {
            throw new ConfigException("Specified config file does not exist: " . $completePath);
        }

        include($completePath);

        if (isset($pffConfig) && is_array($pffConfig)) {
            $this->_config = array_merge($this->_config, $pffConfig);
        } else {
            throw new ConfigException("Failed to load configuration file!
                                            The file seems to be corrupted: " . $completePath);
        }
    }
588043
public function loadFile($path) {
        $config = null;

        try {
            $config = require $path;
        } catch (Exception $ex) {}

        if ( ! is_array($config)) {
            throw new InvalidConfigFormatException(
                s('ArrayConfigDriver expects config at path %s to be of format array[key => value].', $path)
            );
        }

        return $config;
    }
355787
function customConfigIsBeingImported($customConfigPath)
    {
        return strpos($this->files->get($this->configPath), $customConfigPath) !== false;
    }
499646
public static function run($rootPath)
    {
        /*
         * Load initialization config needed to bootstrap application.
         *
         * In order for paths to be customized and still have the standard
         * index.php (web) and nut (CLI) work, there needs to be a standard
         * place these are defined. This is ".bolt.yml" or ".bolt.php" in the
         * project root (determined above).
         *
         * Yes, YAML and PHP are supported here (not both). YAML works for
         * simple values and PHP supports any programmatic logic if required.
         */
        $config = [
            'application' => null,
            'resources'   => null,
            'paths'       => [],
            'services'    => [],
            'extensions'  => [],
        ];

        $rootPath = Path::canonicalize($rootPath);

        if (file_exists($rootPath . '/.bolt.yml')) {
            $yaml = Yaml::parse(file_get_contents($rootPath . '/.bolt.yml')) ?: [];
            $config = array_replace_recursive($config, $yaml);
        } elseif (file_exists($rootPath . '/.bolt.php')) {
            $php = include $rootPath . '/.bolt.php';
        }

        // An extra handler if a PHP bootstrap is provided, allow the bootstrap file to return
        // a pre-initialized Bolt Application rather than the config array.
        if (isset($php) && is_array($php)) {
            $config = array_replace_recursive($config, $php);
        } elseif (isset($php) && $php instanceof Silex\Application) {
            return $php;
        }

        // If application object is provided, assume it is ready to go.
        if ($config['application'] instanceof Silex\Application) {
            return $config['application'];
        }

        $pathResolverFactoryFactory = \Pimple::share(function () use ($rootPath, $config) {
            $pathResolverFactory = new PathResolverFactory();
            $pathResolverFactory->setRootPath($rootPath);
            $pathResolverFactory->addPaths((array) $config['paths']);

            return $pathResolverFactory;
        });

        $resourcesClass = func_num_args() > 1 ? func_get_arg(1) : Standard::class;
        $resourcesFactory = \Pimple::share(function () use ($config, $resourcesClass, $rootPath, $pathResolverFactoryFactory) {
            // Use resources from config, or instantiate the class based on mapping above.
            if ($config['resources'] instanceof ResourceManager) {
                $resources = $config['resources'];
            } else {
                if ($config['resources'] !== null && is_a($config['resources'], ResourceManager::class, true)) {
                    $resourcesClass = $config['resources'];
                }

                $passPathResolverFactory = false;
                if ($resourcesClass === Composer::class || $resourcesClass === Standard::class) {
                    $passPathResolverFactory = true;
                } else {
                    $r = (new \ReflectionClass($resourcesClass))->getConstructor();
                    if ($r->getNumberOfParameters() > 2 && $r->getParameters()[2]->getClass()->name === PathResolverFactory::class) {
                        $passPathResolverFactory = true;
                    }
                }

                /** @var \Bolt\Configuration\ResourceManager $resources */
                if ($passPathResolverFactory) {
                    $pathResolverFactory = $pathResolverFactoryFactory(null);
                    $resources = new $resourcesClass($rootPath, null, $pathResolverFactory);
                } else {
                    $resources = new $resourcesClass($rootPath);
                }
            }

            // Set any non-standard paths
            foreach ((array) $config['paths'] as $name => $path) {
                $resources->setPath($name, $path, false);
            }

            $resources->verify();

            return $resources;
        });

        // If resources is already initialized, go ahead and customize it now.
        if ($config['resources'] instanceof ResourceManager) {
            $resourcesFactory = $resourcesFactory(null);
        }

        // Create the 'Bolt application'
        $appClass = Application::class;
        if ($config['application'] !== null && is_a($config['application'], Silex\Application::class, true)) {
            $appClass = $config['application'];
        }
        /** @var Silex\Application $app */
        $app = new $appClass([
            'resources'             => $resourcesFactory,
            'path_resolver_factory' => $pathResolverFactoryFactory,
            'path_resolver.root'    => $rootPath,
            'path_resolver.paths'   => (array) $config['paths'],
            'resources.bootstrap'   => $config['resources'] !== null,
        ]);

        foreach ((array) $config['services'] as $service) {
            $params = [];
            if (is_array($service)) {
                $params = reset($service);
                $service = key($service);
            }

            if (is_string($service) && is_a($service, Silex\ServiceProviderInterface::class, true)) {
                $service = new $service();
            }
            if ($service instanceof Silex\ServiceProviderInterface) {
                $app->register($service, $params);
            }
        }

        if (!$config['extensions']) {
            return $app;
        }
        if (!isset($app['extensions'])) {
            throw new LogicException('Provided application object does not contain an extension service, but extensions are defined in bootstrap.');
        }

        $app['extensions'] = $app->share(
            $app->extend(
                'extensions',
                function ($extensions) use ($config) {
                    foreach ((array) $config['extensions'] as $extensionClass) {
                        if (is_string($extensionClass)) {
                            if (!class_exists($extensionClass)) {
                                throw new LogicException(sprintf('Extension class name "%s" is defined in .bolt.yml or .bolt.php, but the class name is misspelled or not loadable by Composer.', $extensionClass));
                            }
                            if (!is_a($extensionClass, ExtensionInterface::class, true)) {
                                throw new LogicException(sprintf('Extension class "%s" must implement %s', $extensionClass, ExtensionInterface::class));
                            }
                            $extensionClass = new $extensionClass();
                        }
                        if (!$extensionClass instanceof ExtensionInterface) {
                            throw new LogicException(sprintf('Extension class "%s" must be an instance of %s', get_class($extensionClass), ExtensionInterface::class));
                        }
                        $extensions->add($extensionClass);
                    }

                    return $extensions;
                }
            )
        );

        return $app;
    }
1115649
public function addConfigPath($path)
    {
        if (!file_exists($path) || !is_dir($path) || !is_readable($path)) {
            throw new Exception(
                'Invalid or unreadable path: '.$path,
                Exception::INVALID_PATH
            );
        }
        $this->configPaths[] = $path;

        return $this;
    }
1243535
public function loadWithDefault(string $configPath, string $defaultConfigPath): void
    {
        if (!file_exists($configPath)) {
            return;
        }
        $configDefault = include $defaultConfigPath;
        $config = include $configPath;
        if (!is_array($configDefault) && !is_array($config)) {
            return;
        }
        $this->loadArray(array_merge($configDefault, $config));
    }
1133034
public static function init($configPath = null)
    {
        if (!isset(self::$instances[$configPath])) {
            self::$instances[$configPath] = new IDS_Init($configPath);
        }

        return self::$instances[$configPath];
    }
1357040
public function setConfigPath($path) 
    {
        if (file_exists($path)) {
            $this->configPath = $path;
        } else {
            throw new Exception(
                'Configuration file could not be found at ' .
                htmlspecialchars($path, ENT_QUOTES, 'UTF-8')
            );
        }
    }