Commit 94b25431 authored by Andrew Nicols's avatar Andrew Nicols
Browse files

Merge branch 'mobile-testing' into 'master'

Add support to mobile testing

See merge request integration/nightlyjobs!9
parents 93b90872 042ec110
package org.moodle.ci;
/**
* A Moodle Continuous Integration Moodle plugin to be installed.
*/
class MoodlePlugin {
/**
* The plugin repository URL.
*/
protected String url
/**
* The Moodle folder where the plugin will be installed.
*/
protected String path
/**
* The plugin branch to install.
*/
protected String branch
/**
* The URL of the repository to fetch from.
*
* @return String
*/
String getUrl() {
if (url) {
return url
}
throw new Exception('No URL repository specified.')
}
/**
* The folder where the plugin will be installed.
*
* @return String
*/
String getPath() {
if (path) {
return path
}
throw new Exception('No path specified.')
}
/**
* The plugin branch to install.
*/
String getBranch() {
if (branch) {
return branch
} else {
return ''
}
}
/**
* Get a String in the expected format by the ci-runner.
*
* @return The string format used by the ci-runner.
*/
String getPluginAsString() {
if (url && path) {
return "${url}|${path}|" + getBranch()
}
}
}
......@@ -100,6 +100,16 @@ class Task {
*/
protected String name
/**
* The Moodle app version to be run.
*/
protected String mobileVersion
/**
* External plugins to install.
*/
protected MoodlePlugin[] moodlePlugins = []
/**
* A testsuite to restrict runs to.
*/
......@@ -276,6 +286,43 @@ class Task {
}
}
/**
* Get the Moodle app version to run the Behat tests with the @app tag.
*
* @return The Moodle app version to be run.
*/
def getMobileVersion() {
if (mobileVersion) {
return mobileVersion
} else {
return ""
}
}
/**
* Add a plugin to install.
*
* @param newPlugin The new plugin to install.
*/
def addMoodlePlugin(MoodlePlugin newPlugin) {
moodlePlugins << newPlugin
}
/**
* Get the external plugins to install in the site.
*
* @return The external plugins list to install. The expected format is defined in run.sh from the moodle-ci-runner.
*/
def getPluginsToInstall() {
def pluginString = []
moodlePlugins.each {
pluginString.push(it.getPluginAsString())
}
return pluginString.join(';')
}
/**
* Get the testsuite to be run.
* Currently only used in PHPUnit.
......
package test.org.moodle.ci;
import spock.lang.Specification
import org.moodle.ci.MoodlePlugin
class MoodlePluginSpec extends Specification {
def "getBranch() with no branch"() {
given:
def url = 'git://github.com/moodlehq/moodle-local_codechecker'
def path = 'local/codechecker'
def branch = null
when:
def plugin = new MoodlePlugin(url: url, path: path, branch: branch)
def output = plugin.getBranch()
then:
assert output == ''
}
def "getBranch() with branch"() {
given:
def url = 'git://github.com/moodlehq/moodle-local_codechecker'
def path = 'local/codechecker'
def branch = 'master'
when:
def plugin = new MoodlePlugin(url: url, path: path, branch: branch)
def output = plugin.getBranch()
then:
assert output == 'master'
}
def "getPluginAsString() with no branch"() {
given:
def url = 'git://github.com/moodlehq/moodle-local_codechecker'
def path = 'local/codechecker'
def branch = null
when:
def plugin = new MoodlePlugin(url: url, path: path, branch: branch)
def output = plugin.getPluginAsString()
then:
assert output == 'git://github.com/moodlehq/moodle-local_codechecker|local/codechecker|'
}
def "getPluginAsString() with branch"() {
given:
def url = 'git://github.com/moodlehq/moodle-local_codechecker'
def path = 'local/codechecker'
def branch = 'master'
when:
def plugin = new MoodlePlugin(url: url, path: path, branch: branch)
def output = plugin.getPluginAsString()
then:
assert output == 'git://github.com/moodlehq/moodle-local_codechecker|local/codechecker|master'
}
}
......@@ -2,6 +2,7 @@ package test.org.moodle.ci;
import spock.lang.Specification
import org.moodle.ci.Task
import org.moodle.ci.MoodlePlugin
class TaskSpec extends Specification {
def "getBuildDescription with basics"() {
......@@ -56,6 +57,82 @@ class TaskSpec extends Specification {
assert output == "MDL-12345-34: phpunit pgsql (PHP7.0)"
}
def "getMobileVersion() with no version"() {
given:
def mobileVersion = null
when:
def task = new Task(mobileVersion: mobileVersion)
def output = task.getMobileVersion()
then:
assert output == ''
}
def "getMobileVersion() with next version"() {
given:
def mobileVersion = 'next'
when:
def task = new Task(mobileVersion: mobileVersion)
def output = task.getMobileVersion()
then:
assert output == 'next'
}
def "getPluginsToInstall() with empty value"() {
given:
def moodlePlugins = null
when:
def task = new Task(moodlePlugins: moodlePlugins)
def output = task.getPluginsToInstall()
then:
assert output == ''
}
def "getPluginsToInstall() with codechecker one plugin"() {
given:
def moodlePlugins = [
new org.moodle.ci.MoodlePlugin(
url: 'git://github.com/moodlehq/moodle-local_codechecker',
path: 'local/codechecker',
branch: 'master'
)
]
when:
def task = new Task(moodlePlugins: moodlePlugins)
def output = task.getPluginsToInstall()
then:
assert output == 'git://github.com/moodlehq/moodle-local_codechecker|local/codechecker|master'
}
def "getPluginsToInstall() with codechecker more than one plugin"() {
given:
def moodlePlugins = [
new org.moodle.ci.MoodlePlugin(
url: 'git://github.com/moodlehq/moodle-local_codechecker',
path: 'local/codechecker',
branch: 'master'
),
new org.moodle.ci.MoodlePlugin(
url: 'https://github.com/moodlehq/moodle-local_moodlemobile',
path: 'local/moodlemobile'
),
]
when:
def task = new Task(moodlePlugins: moodlePlugins)
def output = task.getPluginsToInstall()
then:
assert output == 'git://github.com/moodlehq/moodle-local_codechecker|local/codechecker|master;https://github.com/moodlehq/moodle-local_moodlemobile|local/moodlemobile|'
}
def "getSuiteName() with no suite"() {
given:
def suite = null
......
......@@ -13,6 +13,8 @@ def call(org.moodle.ci.Task task) {
BROWSER = "${task.browserName}"
TAGS = "${task.tags}"
NAME = "${task.name}"
MOBILE_VERSION = "${task.mobileVersion}"
PLUGINSTOINSTALL= task.getPluginsToInstall()
TESTSUITE = "${task.testsuite}"
BEHAT_SUITE = "${task.suite}"
BEHAT_TIMING_FILENAME = "${task.timingFileName}"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment