# HG changeset patch # User Diggory Hardy # Date 1215193756 -3600 # Node ID 3a737e06dc50fe9981cb9821ee296033c97733c2 # Parent 108d123238c01a7a5760e9f5ff74d8835b837642 Unittests: fixes and changes. Plus some doc changes. diff -r 108d123238c0 -r 3a737e06dc50 data/conf/input.mtt --- a/data/conf/input.mtt Thu Jul 03 12:40:31 2008 +0100 +++ b/data/conf/input.mtt Fri Jul 04 18:49:16 2008 +0100 @@ -2,14 +2,3 @@ ! {Default} -{UnitTest} - - - diff -r 108d123238c0 -r 3a737e06dc50 doc/Building.txt --- a/doc/Building.txt Thu Jul 03 12:40:31 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ ---- Dependencies --- -Compile-time: -tango 0.99.6 -tango.scrapple -derelict (at least revision 300) - -Run-time: -Sdl -FreeType 2.3.5 (2.3.0 might work; older versions probably won't due to the binding not finding some (unneeded) symbols). -OpenGL 1.3 or higher - - ---- Building --- -dsss build -bin/mde or bin\mde (depending on platform) - -See the readme for more information. diff -r 108d123238c0 -r 3a737e06dc50 doc/Readme.txt --- a/doc/Readme.txt Thu Jul 03 12:40:31 2008 +0100 +++ b/doc/Readme.txt Fri Jul 04 18:49:16 2008 +0100 @@ -1,11 +1,23 @@ Copyright © 2007-2008 Diggory Hardy License: GNU General Public License version 2 or later (see COPYING) -Some brief info: +--- Some brief info --- + +-- Platforms -- +Linux: My development platform. +Windows: Poorly tested; dsss.conf needs some adjusting. -Platforms: -I work on mde using linux and perform most testing on this platform. -I have done a little testing on Windows, but currently it's highly likely there may be problems on this platform. +-- Dependencies -- +Compile-time: +tango (at least r3697) +tango.scrapple (newer than current r58!) +derelict (at least r300) + +Run-time: +Sdl +FreeType 2.3.5 (2.3.0 might work; older versions probably won't due to the binding not finding some (unneeded) symbols). +OpenGL 1.3 or higher + Build instructions: dsss build @@ -14,7 +26,8 @@ Testing: dsss clean (this is important if a previous build exists!) -dsss build bin/mdeTest +dsss build -debug -debug=mdeUnitTest -C-unittest +bin/mde or bin\mde Credits: Me (Diggory Hardy) for just about everything in mde as of now. diff -r 108d123238c0 -r 3a737e06dc50 dsss.conf --- a/dsss.conf Thu Jul 03 12:40:31 2008 +0100 +++ b/dsss.conf Fri Jul 04 18:49:16 2008 +0100 @@ -16,11 +16,3 @@ [util/mtcp.d] target=bin/mtcp - -[test/mdeTest.d] -buildflags=-debug -debug=mdeUnitTest -unittest -target=bin/mdeTest -noinstall -version (Posix) { - buildflags+=-L-ldl -} diff -r 108d123238c0 -r 3a737e06dc50 mde/input/Config.d --- a/mde/input/Config.d Thu Jul 03 12:40:31 2008 +0100 +++ b/mde/input/Config.d Fri Jul 04 18:49:16 2008 +0100 @@ -154,8 +154,9 @@ if (file_configs) file.read(file_configs); // restrict to this set IF a restriction was given else file.read(); // otherwise read all } - catch (MT.MTException) { - logger.fatal ("Unable to load configs from: " ~ filename); + catch (MT.MTException e) { + logger.fatal ("Unable to load configs from: " ~ filename ~ ":"); + logger.fatal (e.msg); throw new ConfigLoadException; } diff -r 108d123238c0 -r 3a737e06dc50 mde/input/Input.d --- a/mde/input/Input.d Thu Jul 03 12:40:31 2008 +0100 +++ b/mde/input/Input.d Fri Jul 04 18:49:16 2008 +0100 @@ -349,8 +349,8 @@ * * Throws: ConfigLoadException if unable to load any configs or the requested config id wasn't * found. */ - void loadConfig (char[] profile = "Default") { - Config.load("input"); // FIXME: filename + void loadConfig (char[] file, char[] profile = "Default") { + Config.load(file); Config* c_p = profile in Config.configs; if (c_p) config = *c_p; else { @@ -545,7 +545,7 @@ /* This unittest covers input.config.Config and input.input.Input for some events of all types. - * It is not bullet-proof, and does not cover the steam-functions other than the direct output + * It is not bullet-proof, and does not cover the stream-functions other than the direct output * ones (largely because these may get added at any time and tested via input tests). * * What it does test: @@ -557,7 +557,7 @@ * currently conf/input.mtt). */ debug (mdeUnitTest) unittest { Input ut = new Input(); - ut.loadConfig ("UnitTest"); + ut.loadConfig ("unittest/InputConfig"); int[6] counters; // counters for callbacks // Should become: [2,2,0,2,1,1] diff -r 108d123238c0 -r 3a737e06dc50 mde/mde.d --- a/mde/mde.d Thu Jul 03 12:40:31 2008 +0100 +++ b/mde/mde.d Fri Jul 04 18:49:16 2008 +0100 @@ -40,6 +40,10 @@ { //BEGIN Initialisation Logger logger = Log.getLogger ("mde.mde"); + debug (mdeUnitTest) { + logger.info ("Compiled unittests have completed; terminating."); + return 0; + } // Create instances now, so they can be used during init (if necessary) input = new Input(); diff -r 108d123238c0 -r 3a737e06dc50 mde/setup/init2.d --- a/mde/setup/init2.d Thu Jul 03 12:40:31 2008 +0100 +++ b/mde/setup/init2.d Fri Jul 04 18:49:16 2008 +0100 @@ -71,7 +71,7 @@ void initInput () { // init func try { - imde.input.loadConfig (); // (may also create instance) + imde.input.loadConfig ("input"); // Quit on escape. NOTE: quit via SDL_QUIT event is handled completely independently! imde.input.addButtonCallback (cast(Input.inputID) 0x0u, delegate void(Input.inputID i, bool b) { diff -r 108d123238c0 -r 3a737e06dc50 mde/setup/paths.d --- a/mde/setup/paths.d Thu Jul 03 12:40:31 2008 +0100 +++ b/mde/setup/paths.d Fri Jul 04 18:49:16 2008 +0100 @@ -131,6 +131,18 @@ readOrder == PRIORITY.HIGH_ONLY ); } body { FilePath[] ret; + + debug (mdeUnitTest) { + /* Alternate approach - just try from current directory. + * Really just for unittests, but with the if condition it shouldn't break anything else. */ + if (pathsLen == 0) { + FilePath file = findFile (filename); + if (file !is null) + ret ~= file; + return ret; + } + } + if (readOrder == PRIORITY.LOW_HIGH) { for (size_t i = 0; i < pathsLen; ++i) { FilePath file = findFile (paths[i]~filename); diff -r 108d123238c0 -r 3a737e06dc50 test/mdeTest.d --- a/test/mdeTest.d Thu Jul 03 12:40:31 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* LICENSE BLOCK -Part of mde: a Modular D game-oriented Engine -Copyright © 2007-2008 Diggory Hardy - -This program 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 2 of the License, or (at your option) any later version. - -This program 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 program. If not, see . */ - -/** A module to run all mde unittests and potentially to perform other tests. -* -* Purpose: an easy mechanism to perform all tests. -* -* Unittests do NOT require this module to run, however since the full executable may become complex -* and thus not be the ideal tool to perform testing, tests may also be run from here. -*/ -module test.mdeTest; - -// This module should import all mde modules containing unittests: -import mde.input.input; -import mde.mergetag.DataSet; -import mde.mergetag.mtunittest; -import mde.exception; -import mde.scheduler.Init; -import mde.scheduler.Scheduler; -import mde.i18n.I18nTranslation; - -import tango.util.log.Log : Log, Logger; - -private Logger logger; - -static this() -{ - // In case no console-appender is added by Init, add one here (doesn't hurt if it's an extra) - Log.getRootLogger.addAppender(new ConsoleAppender); - - logger = Log.getLogger ("test.mdeTest"); - - logger.info ("Running unittests..."); - logger.info ("Note: you will probably need to clean before building to run all unittests"); - logger.info ("−−−−−−−−"); -} - -void main() { - logger.info ("−−−−−−−−"); - logger.info ("All unittests complete."); -} diff -r 108d123238c0 -r 3a737e06dc50 unittest/InputConfig.mtt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/unittest/InputConfig.mtt Fri Jul 04 18:49:16 2008 +0100 @@ -0,0 +1,13 @@ +{MT01} +!{Config for the input.Input unittest} +{Default} + + +