diff options
-rw-r--r-- | npc/dev/ci_test.txt | 22 | ||||
-rw-r--r-- | src/plugins/script_mapquit.c | 47 | ||||
-rwxr-xr-x | travis.sh | 28 |
3 files changed, 80 insertions, 17 deletions
diff --git a/npc/dev/ci_test.txt b/npc/dev/ci_test.txt new file mode 100644 index 000000000..058d25ad5 --- /dev/null +++ b/npc/dev/ci_test.txt @@ -0,0 +1,22 @@ +//===== Hercules Script ====================================== +//= Script engine self-tests, CI integration +//===== By: ================================================== +//= Haru +//===== Current Version: ===================================== +//= 1.0 +//===== Description: ========================================= +//= This script depends on npc/dev/test.txt, and extends it so +// that it can be called in a CI environment and returns an +// appropriate value upon termination. +//= This script is part of the script_mapquit plugin +// distribution, and requires said plugin to be loaded. +//= Usage: ./map-server --load-plugin script_mapquit --load-script npc/dev/test.txt --load-script npc/dev/ci_test.txt + +- script HerculesSelfTestCI -1,{ + end; + +OnInit: + .@val = callfunc("HerculesSelfTestHelper"); + mapquit(.@val); + end; +} diff --git a/src/plugins/script_mapquit.c b/src/plugins/script_mapquit.c new file mode 100644 index 000000000..e44582db7 --- /dev/null +++ b/src/plugins/script_mapquit.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Hercules Dev Team + * Base author: Haru <haru@dotalux.com> + * + * This plugin is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This plugin is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this plugin. If not, see <http://www.gnu.org/licenses/>. + */ + +/// mapquit() script command + +#include "common/HPMi.h" +#include "map/map.h" +#include "map/script.h" + +#include "common/HPMDataCheck.h" + +HPExport struct hplugin_info pinfo = { + "script_mapquit", // Plugin name + SERVER_TYPE_MAP, // Which server types this plugin works with? + "0.1", // Plugin version + HPM_VERSION, // HPM Version (don't change, macro is automatically updated) +}; + +BUILDIN(mapquit) { + if (script_hasdata(st, 2)) { + map->retval = script_getnum(st, 2); + } + map->do_shutdown(); + return true; +} +HPExport void server_preinit(void) { + map = GET_SYMBOL("map"); + script = GET_SYMBOL("script"); +} +HPExport void plugin_init(void) { + addScriptCommand("mapquit", "?", mapquit); +} @@ -57,9 +57,7 @@ case "$MODE" in (cd tools && ./validateinterfaces.py silent) || aborterror "Interface validation error." ./configure $@ || aborterror "Configure error, aborting build." make sql -j3 || aborterror "Build failed." - if [ -f src/plugins/script_mapquit.c ]; then - make plugin.script_mapquit -j3 || aborterror "Build failed." - fi + make plugin.script_mapquit -j3 || aborterror "Build failed." ;; test) cat >> conf/import/login_conf.txt << EOF @@ -92,25 +90,21 @@ log_db_ip: localhost EOF [ $? -eq 0 ] || aborterror "Unable to import configuration, aborting tests." ARGS="--load-script npc/dev/test.txt " - if [ -f src/plugins/script_mapquit.c ]; then - ARGS="--load-plugin script_mapquit $ARGS --load-script npc/dev/ci_test.txt" - fi + ARGS="--load-plugin script_mapquit $ARGS --load-script npc/dev/ci_test.txt" echo "Running Hercules with command line: ./map-server --run-once $ARGS" ./map-server --run-once $ARGS || aborterror "Test failed." ;; getplugins) echo "Cloning plugins repository..." - git clone http://github.com/HerculesWS/StaffPlugins.git || aborterror "Unable to fetch plugin repository" - if [ -f StaffPlugins/Haru/script_mapquit/script_mapquit.c -a -f StaffPlugins/Haru/script_mapquit/examples/ci_test.txt ]; then - pushd src/plugins || aborterror "Unable to enter plugins directory." - ln -s ../../StaffPlugins/Haru/script_mapquit/script_mapquit.c ./ - popd - pushd npc/dev || aborterror "Unable to enter scripts directory." - ln -s ../../StaffPlugins/Haru/script_mapquit/examples/ci_test.txt ./ - popd - else - echo "Plugin not found, skipping advanced tests." - fi + # Nothing to clone right now, all relevant plugins are part of the repository. + #git clone http://github.com/HerculesWS/StaffPlugins.git || aborterror "Unable to fetch plugin repository" + #if [ -f StaffPlugins/Haru/script_mapquit/script_mapquit.c -a -f StaffPlugins/Haru/script_mapquit/examples/ci_test.txt ]; then + # pushd src/plugins || aborterror "Unable to enter plugins directory." + # ln -s ../../StaffPlugins/Haru/script_mapquit/script_mapquit.c ./ + # popd + #else + # echo "Plugin not found, skipping advanced tests." + #fi ;; *) usage |