Beispiel #1
0
    echo "Acceptance tests site installed for sites:" . PHP_EOL;
    // Display all sites which are installed/drop/diabled.
    for ($i = $options['fromrun']; $i <= $options['torun']; $i++) {
        if (empty($CFG->behat_parallel_run[$i - 1]['behat_wwwroot'])) {
            echo $CFG->behat_wwwroot . "/" . BEHAT_PARALLEL_SITE_NAME . $i . PHP_EOL;
        } else {
            echo $CFG->behat_parallel_run[$i - 1]['behat_wwwroot'] . PHP_EOL;
        }
    }
} else {
    if ($options['drop']) {
        echo "Acceptance tests site dropped for " . $options['parallel'] . " parallel sites" . PHP_EOL;
    } else {
        if ($options['enable']) {
            echo "Acceptance tests environment enabled on {$CFG->behat_wwwroot}, to run the tests use:" . PHP_EOL;
            echo behat_command::get_behat_command(true, true);
            echo PHP_EOL;
        } else {
            if ($options['disable']) {
                echo "Acceptance tests environment disabled for " . $options['parallel'] . " parallel sites" . PHP_EOL;
            } else {
                echo $help;
            }
        }
    }
}
chdir($cwd);
exit(0);
/**
 * Create commands to be executed for parallel run.
 *
Beispiel #2
0
 /**
  * Renders an error message adding the generic info about the tool purpose and setup.
  *
  * @param string $msg The error message
  * @return string HTML
  */
 public function render_error($msg)
 {
     $html = $this->generic_info();
     $a = new stdClass();
     $a->errormsg = $msg;
     $a->behatcommand = behat_command::get_behat_command();
     $a->behatinit = 'php admin' . DIRECTORY_SEPARATOR . 'tool' . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . 'cli' . DIRECTORY_SEPARATOR . 'init.php';
     $msg = get_string('wrongbehatsetup', 'tool_behat', $a);
     // Error box including generic error string + specific error msg.
     $html .= $this->output->box_start('box errorbox');
     $html .= html_writer::tag('div', $msg);
     $html .= $this->output->box_end();
     $html .= $this->output->footer();
     return $html;
 }
Beispiel #3
0
        } else {
            $CFG->behat_dataroot = $behatdataroot . $i;
        }
        behat_config_manager::update_config_file('', true, $tags);
    }
    $CFG->behat_dataroot = $behatdataroot;
    $CFG->behat_wwwroot = $behatwwwroot;
    unset($CFG->behatrunprocess);
}
$cmds = array();
echo "Running " . ($options['torun'] - $options['fromrun'] + 1) . " parallel behat sites:" . PHP_EOL;
for ($i = $options['fromrun']; $i <= $options['torun']; $i++) {
    $CFG->behatrunprocess = $i;
    // Options parameters to be added to each run.
    $myopts = !empty($options['replace']) ? str_replace($options['replace'], $i, $extraopts) : $extraopts;
    $behatcommand = behat_command::get_behat_command(false, false, true);
    $behatconfigpath = behat_config_manager::get_behat_cli_config_filepath($i);
    // Command to execute behat run.
    $cmds[BEHAT_PARALLEL_SITE_NAME . $i] = $behatcommand . ' --config ' . $behatconfigpath . " " . $myopts;
    echo "[" . BEHAT_PARALLEL_SITE_NAME . $i . "] " . $cmds[BEHAT_PARALLEL_SITE_NAME . $i] . PHP_EOL;
}
if (empty($cmds)) {
    echo "No commands to execute " . PHP_EOL;
    exit(1);
}
// Create site symlink if necessary.
if (!behat_config_manager::create_parallel_site_links($options['fromrun'], $options['torun'])) {
    echo "Check permissions. If on windows, make sure you are running this command as admin" . PHP_EOL;
    exit(1);
}
// Execute all commands.
Beispiel #4
0
require_once $CFG->libdir . '/behat/classes/util.php';
require_once $CFG->libdir . '/behat/classes/behat_command.php';
// Run command (only one per time).
if ($options['install']) {
    behat_util::install_site();
    mtrace("Acceptance tests site installed");
} else {
    if ($options['drop']) {
        // Ensure no tests are running.
        test_lock::acquire('behat');
        behat_util::drop_site();
        mtrace("Acceptance tests site dropped");
    } else {
        if ($options['enable']) {
            behat_util::start_test_mode();
            $runtestscommand = behat_command::get_behat_command(true) . ' --config ' . behat_config_manager::get_behat_cli_config_filepath();
            mtrace("Acceptance tests environment enabled, to run the tests use:\n " . $runtestscommand);
        } else {
            if ($options['disable']) {
                behat_util::stop_test_mode();
                mtrace("Acceptance tests environment disabled");
            } else {
                if ($options['diag']) {
                    $code = behat_util::get_behat_status();
                    exit($code);
                } else {
                    echo $help;
                }
            }
        }
    }
            } else {
                if ($options['diag']) {
                    $code = behat_util::get_behat_status();
                    exit($code);
                } else {
                    if ($options['updatesteps']) {
                        if (defined('BEHAT_FEATURE_STEP_FILE') && BEHAT_FEATURE_STEP_FILE) {
                            $behatstepfile = BEHAT_FEATURE_STEP_FILE;
                        } else {
                            echo "BEHAT_FEATURE_STEP_FILE is not set, please ensure you set this to writable file" . PHP_EOL;
                            exit(1);
                        }
                        // Rewrite config file to ensure we have all the features covered.
                        behat_config_manager::update_config_file();
                        // Run behat command to get steps in feature files.
                        $featurestepscmd = behat_command::get_behat_command(true);
                        $featurestepscmd .= ' --config ' . behat_config_manager::get_behat_cli_config_filepath();
                        $featurestepscmd .= ' --dry-run --format=moodle_step_count';
                        $processes = cli_execute_parallel(array($featurestepscmd), __DIR__ . "/../../../../");
                        $status = print_update_step_output(array_pop($processes), $behatstepfile);
                        exit($status);
                    } else {
                        echo $help;
                        exit(1);
                    }
                }
            }
        }
    }
}
exit(0);
require_once $CFG->libdir . '/behat/classes/util.php';
require_once $CFG->libdir . '/behat/classes/behat_command.php';
// Run command (only one per time).
if ($options['install']) {
    behat_util::install_site();
    mtrace("Acceptance tests site installed");
} else {
    if ($options['drop']) {
        // Ensure no tests are running.
        test_lock::acquire('behat');
        behat_util::drop_site();
        mtrace("Acceptance tests site dropped");
    } else {
        if ($options['enable']) {
            behat_util::start_test_mode();
            $runtestscommand = behat_command::get_behat_command() . ' --config ' . $CFG->behat_dataroot . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . 'behat.yml';
            mtrace("Acceptance tests environment enabled, to run the tests use:\n " . $runtestscommand);
        } else {
            if ($options['disable']) {
                behat_util::stop_test_mode();
                mtrace("Acceptance tests environment disabled");
            } else {
                if ($options['diag']) {
                    $code = behat_util::get_behat_status();
                    exit($code);
                } else {
                    echo $help;
                }
            }
        }
    }
Beispiel #7
0
            $CFG->behat_wwwroot = $behatwwwroot . "/" . BEHAT_PARALLEL_SITE_NAME . $i;
        }
        behat_config_manager::update_config_file('', true, $tags);
    }
    $CFG->behat_dataroot = $behatdataroot;
    $CFG->behat_wwwroot = $behatwwwroot;
    unset($CFG->behatrunprocess);
}
$cmds = array();
$extraopts = implode(' ', $extraopts);
echo "Running " . ($options['torun'] - $options['fromrun'] + 1) . " parallel behat sites:" . PHP_EOL;
for ($i = $options['fromrun']; $i <= $options['torun']; $i++) {
    $CFG->behatrunprocess = $i;
    // Options parameters to be added to each run.
    $myopts = !empty($options['replace']) ? str_replace($options['replace'], $i, $extraopts) : $extraopts;
    $behatcommand = behat_command::get_behat_command();
    $behatconfigpath = behat_config_manager::get_behat_cli_config_filepath($i);
    // Command to execute behat run.
    $cmds[BEHAT_PARALLEL_SITE_NAME . $i] = $behatcommand . ' --config ' . $behatconfigpath . " " . $myopts;
    echo "[" . BEHAT_PARALLEL_SITE_NAME . $i . "] " . $cmds[BEHAT_PARALLEL_SITE_NAME . $i] . PHP_EOL;
}
if (empty($cmds)) {
    echo "No commands to execute " . PHP_EOL;
    exit(1);
}
// Execute all commands.
$processes = cli_execute_parallel($cmds);
$stoponfail = empty($options['stop-on-failure']) ? false : true;
// Print header.
print_process_start_info($processes);
// Print combined run o/p from processes.