Форк Rambox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
8.2 KiB

<?xml version="1.0" encoding="utf-8"?>
<!--
********************************** DO NOT EDIT **********************************
This file will be replaced during upgrades so DO NOT EDIT this file. If you need to
adjust the process, reading and understanding this file is the first step.
In most cases, the adjustments can be achieved by setting properties or providing one
of the "hooks" in the form of a "-before-" or "-after-" target. Whenever possible, look
for one of these solutions.
Failing that, you can copy whole targets to your build.xml file and it will overrride
the target provided here. Doing that can create problems for upgrading to newer
versions of Cmd so it is not recommended but it will be easier to manage than editing
this file in most cases.
-->
<project name="cmd-test">
<target name="-before-test-init"/>
<target name="-test-init">
<condition property="environment.dir" value="${app.dir}">
<isset property="${app.dir}"/>
</condition>
<property name="environment.dir" value="${package.dir}"/>
<property name="cmd-test.specs.dir" value="${environment.dir}/test/specs"/>
<property name="cmd-test.specs.test-json" value="${cmd-test.specs.dir}/test.json"/>
<available file="${cmd-test.specs.test-json}" property="cmd-test.available"/>
</target>
<target name="-after-test-init"/>
<target name="test-init"
depends="init,-before-test-init,-test-init,-after-test-init"/>
<target name="-before-test-console"/>
<target name="-test-console" depends="test-bootstrap">
<echo>Launching Sencha Test Console</echo>
<echo>using cmd.dir : ${cmd.dir}</echo>
<x-sencha-command
dir="cmd-test.specs.dir">
<property name="cmd-test.run.launch-browser"
value="${cmd-test.run.launch-browser}"/>
test
console
-configFile
${cmd-test.specs.test-json}
</x-sencha-command>
</target>
<target name="-after-test-console"/>
<target name="test-console"
depends="test-init,-before-test-console,-test-console,-after-test-console"
description="Run tests"/>
<target name="-before-test-run"/>
<target name="-test-run" depends="test-bootstrap">
<echo>Launching Sencha Test Runner</echo>
<echo>using cmd.dir : ${cmd.dir}</echo>
<x-sencha-command
dir="cmd-test.specs.dir">
test
run
-configFile
${cmd-test.specs.test-json}
</x-sencha-command>
</target>
<target name="-after-test-run"/>
<target name="test-run"
depends="test-init,-before-test-run,-test-run,-after-test-run"
description="Run tests"/>
<target name="-before-test-bootstrap"/>
<target name="-test-bootstrap" if="${cmd-test.available}">
<local name="local.runner.dir"/>
<local name="console.runner.dir"/>
<local name="specfiles.list"/>
<local name="base.path"/>
<property name="local.runner.dir" value="${environment.dir}/test/local"/>
<property name="console.runner.dir" value="${environment.dir}/test/specs"/>
<property name="base.path" value="${local.runner.dir}"/>
<property name="bootstrap.specs.file" value="../bootstrap-specs.js"/>
<x-bootstrap file="${base.path}/../bootstrap.js"
basedir="${base.path}"
coreFilesFile="${base.path}/../bootstrap-files.js"
includeBoot="true"
includeManifest="true"
includeCoreFiles="true"
appendCoreFiles="false"
includeMetadata="false"
appendClassMetadata="false"
includeOverrides="false"
overrideExcludeTags="">
<![CDATA[
Ext.Boot.loadSync([
"../bootstrap-files.js"
]);
Ext.Boot.load([
"../bootstrap-launch.js"
]);
]]>
</x-bootstrap>
<!--
for the local runner, we also need to include all spec files in the bootstrap
info
-->
<x-script-def name="x-load-specs">
<attribute name="base"/>
<attribute name="property"/>
<attribute name="configprop"/>
<script src="${cmd.dir}/ant/ant-util.js"/>
<![CDATA[
importPackage(com.sencha.util);
importPackage(com.sencha.logging);
var logger = SenchaLogManager.getLogger(),
specDir = project.getProperty('cmd-test.specs.dir') + '',
propName = attributes.get("property") + '',
basePath = attributes.get("base") + '',
configPropName = attributes.get("configprop"),
config = readConfig(joinPath(specDir, 'test.json')),
getScriptFiles = function(path, basePath) {
var converted = [],
files = FileUtil.getAllFilesByExtension(path, ".js"),
length = files.size(), file, f,
relPath;
for(f = 0; f < length; f++) {
file = files.get(f);
logger.debug("getting relpath from {} to {}", basePath, file);
relPath = PathUtil.getRelativePath(basePath, file);
relPath = PathUtil.convertPathCharsToUnix(relPath);
converted.push('"' + relPath + '"');
}
return converted;
},
shuffle = function(input, factor) {
if (!factor)
return input;
var i, f,
reverse = factor < 0,
output = [];
factor = Math.abs(factor);
for (f = 0; f < factor; f++) {
for (i = f; i < input.length; i = i + factor) {
output.push(input[i]);
}
}
return reverse ? output.reverse() : output;
},
files = config[configPropName].src || [],
shuffleFactor = config[configPropName].shuffle || 0,
len = files.length, file, f,
relPath,
converted = [],
shuffled = [];
for(f = 0; f < len; f++) {
file = files[f];
if(!PathUtil.isAbsolute(file)) {
file = PathUtil.join(specDir, file);
}
file = PathUtil.getCanonicalPath(file);
converted = converted.concat(getScriptFiles(file, basePath));
}
// FileUtil.getAllFilesByExtension returns files in a different order
// depending on OS. This sort ensures the files are always ordered the same.
converted.sort(function(a, b) {
return (a < b) ? -1 : (a > b) ? 1 : 0
});
shuffled = shuffle(converted, shuffleFactor);
project.setNewProperty(propName, StringUtil.join(shuffled, ',\n'));
]]>
</x-script-def>
<x-load-specs base="${local.runner.dir}" property="specfiles.list" configprop="specs"/>
<echo file="${local.runner.dir}/${bootstrap.specs.file}"><![CDATA[
(function() {
var url = [
${specfiles.list}
];
if (window.Cmd) {
url = Cmd.status.getCurrentChunk(url);
}
Ext.Boot.load({
charset: "UTF-8",
url: url,
success: function() {
Ext.Boot.load('../start-tests.js');
}
});
})();
]]>
</echo>
</target>
<target name="-after-test-bootstrap"/>
<target name="test-bootstrap"
depends="test-init,-before-test-bootstrap,-test-bootstrap,-after-test-bootstrap"
description="Re-generate the bootstrap info for local and console test harnesses"/>
</project>