project_root
|--src
|-- main
|-- webapp
|-- index.html
|-- js
|-- dojo
|-- dijit
|-- dojox
|-- util
|-- jla
|-- test
|-- dojo-test.sh
|-- dojo-test-config.js
|-- jla
|--test.js
> cd ${project_root}/src/main/webapp/js/test
> ./dojo-test.sh -m jla/app/test
#!/bin/bash
log() {
printf " %25s: %s\n" $1 $2
}
format() {
printf " %25s: %s\n" $1 $2
}
PROJECT_DIR='../../../../../'
log 'PROJECT_DIR' $(readlink -f $PROJECT_DIR)
SOURCE_DIR=$PROJECT_DIR'src/main/webapp/js'
log 'SOURCE_DIR' $(readlink -f $SOURCE_DIR)
JLA_DIR=$SOURCE_DIR'/jla'
log 'JLA_DIR' $(readlink -f $JLA_DIR)
DOJO_DIR=$SOURCE_DIR'/dojo'
log 'DOJO_DIR' $(readlink -f $DOJO_DIR)
ABS_DOJO_DIR=$(readlink -f $DOJO_DIR)
log 'ABS_DOJO_DIR' $ABS_DOJO_DIR
BASE_URL='file://'$ABS_DOJO_DIR
log 'BASE_URL' $BASE_URL
DOJO_JS=$DOJO_DIR'/dojo.js'
log 'DOJO_JS' $(readlink -f $DOJO_JS)
TEST_EXECUTOR=$SOURCE_DIR'/util/shrinksafe/js.jar'
log 'TEST_EXECUTOR' $(readlink -f $TEST_EXECUTOR)
CONFIG_FILE='dojo-test-config.js'
CONFIG_PATH='file://'$(readlink -f $CONFIG_FILE)
log 'CONFIG_PATH' $CONFIG_PATH
TARGET_MODULE=
if [ "$1" = "-m" ] ; then
shift
TARGET_MODULE=$1
shift
fi
CURRENT_DIR='.'
echo 'Test dojo modules:'
format 'CURRENT_DIR' $(readlink -f $CURRENT_DIR)
format 'PROJECT' $(readlink -f $PROJECT_DIR)
format 'EXECUTOR' $TEST_EXECUTOR
format 'DOJO.JS' $DOJO_JS
format 'BASE_URL' $BASE_URL
format 'CONFIG' $CONFIG_PATH
format 'TEST' $TARGET_MODULE
echo 'Testing...'
java -jar $TEST_EXECUTOR $DOJO_JS baseUrl=$BASE_URL load=file://$CONFIG load=doh test=$TARGET_MODULE
require({
paths: {
//путь относительно файла dojo.js
"jla" : "../test/jla"
}
});
org.mozilla.javascript.WrappedException: Wrapped java.io.FileNotFoundException: (Нет такого файла или каталога)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1654)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:175)
at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:411)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen.c2._c11(Unknown Source)
at org.mozilla.javascript.gen.c2.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.c1._c82(Unknown Source)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen.c1._c7(Unknown Source)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen.c1._c38(Unknown Source)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:57)
at org.mozilla.javascript.gen.c1._c74(Unknown Source)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen.c1._c37(Unknown Source)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen.c1._c42(Unknown Source)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen.c1._c11(Unknown Source)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2347)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:272)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:127)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.c1._c1(Unknown Source)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen.c1._c0(Unknown Source)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
at org.mozilla.javascript.gen.c1.call(Unknown Source)
at org.mozilla.javascript.gen.c1.exec(Unknown Source)
at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:526)
at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:448)
at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:414)
at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:405)
at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:179)
at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:100)
at org.mozilla.javascript.Context.call(Context.java:499)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
at org.mozilla.javascript.tools.shell.Main.exec(Main.java:162)
at org.mozilla.javascript.tools.shell.Main.main(Main.java:140)
Caused by: java.io.FileNotFoundException: (Нет такого файла или каталога)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at org.mozilla.javascript.tools.shell.Global.readUrl(Global.java:875)
at org.mozilla.javascript.tools.shell.Global.readUrl(Global.java:661)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:160)
... 48 more
http://path/to/project_root/src/main/webapp/js/util/doh/runner.html?paths=jla,../../../js/test/jla&test=jla/settings
то все работает нормально: тест запускается и успешно проходится.project_root
|--src
|-- main
|-- webapp
|-- index.html
|-- js
|-- dtk
|-- dojo
|-- dijit
|-- dojox
|-- util
|-- jla
|-- some
|-- module.js
|-- test
|-- dojo-test.sh
|-- dojo-test-config.js
|-- jla
|-- root-test.js
|-- some
|-- test.js
#!/bin/bash
# Скрипт для запуска тестов проект. Имеет два способа запуска:
# 1) Запуск тестирования всего проекта:
# ./dojo-test.sh
# При этом в качестве основного теста выступает тест
# ${project_root}/jla-web-app/src/main/webapp/js/test/jla/root-test.js,
# который запускает остальные тесты
# 2) Запуск конкретного теста:
# ./dojo-test.sh -t test/some/test
format() {
printf " %25s: %s\n" $1 $2
}
# как оказалось запускать тестирование нужно из этой директории (тут путь взят относительно директории скрипта):
cd ../dtk/util/doh
CURRENT_DIR='.'
SOURCE_DIR='../../../'
PROJECT_DIR=$SOURCE_DIR'../../../../'
DOJO_DIR=$SOURCE_DIR'dtk/dojo'
DOJO_JS=$DOJO_DIR'/dojo.js'
RHINO=$SOURCE_DIR'dtk/util/shrinksafe/js.jar'
CONFIG_FILE=$SOURCE_DIR'test/dojo-test-config.js'
TARGET_MODULE=
if [ "$1" = "-t" ] ; then
shift
TARGET_MODULE=$1
shift
else
TARGET_MODULE='test/root-test'
fi
echo''
echo 'Testing project '$(readlink -f $PROJECT_DIR)':'
echo''
format 'RHINO' $RHINO
format 'DOJO.JS' $DOJO_JS
format 'BASE_URL' $DOJO_DIR
format 'CONFIG' $CONFIG_FILE
format 'TESTS' $TARGET_MODULE
echo''
echo 'Run test '$TARGET_MODULE'...'
java -jar $RHINO $DOJO_JS baseUrl=$BASE_URL load=$CONFIG_FILE load=doh test=$TARGET_MODULE
require({
//пути задаются относительно файла dojo.js
paths: {
//путь к исходникам jla
"jla" : "../../jla",
//путь к тестам jla
"test" : "../../test/jla"
}
});
${project_root}/src/main/webapp/js/jla
${project_root}/src/main/webapp/js/test/jla
define(["doh/runner"], function(doh) {
doh.register("Tests group name", {
name: "Test name",
setUp: function() {
//тут инициализация чего
},
runTest: function() {
require(["jla/some/module"], function(module) {
//тут собственно тестируем наш модуль module
});
},
tearDown: function() {
//тут действия после тестирования
}
});
});
${project_root}/src/main/webapp/js/dtk/util/doh
./dojo-test.sh -t test/some/test
${project_root}/src/main/webapp/js/test/jla/
define([
"doh/runner",
"test/some/test1",
"test/some/test2"
//собственно тут перечисляем все тесты, которые хотим запустить
], function(doh) {
return 1;//почему-то нужно что-то обязательно вернуть, вероятно по другому Dojo Loader не понимает, что это модуль и не грузит его
});
./dojo-test.sh
http://sin2/js/dtk/util/doh/runner.html?paths=jla,../../../js/jla;test,../../../js/test/jla&test=test/some/test
${project_root}/src/main/webapp/
paths=jla,../../../js/jla;test,../../../js/test/jla
test=test/some/test
test=test/root-test