changeset 68:3a737e06dc50

Unittests: fixes and changes. Plus some doc changes.
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 04 Jul 2008 18:49:16 +0100
parents 108d123238c0
children ead4afc6d0b8
files data/conf/input.mtt doc/Building.txt doc/Readme.txt dsss.conf mde/input/Config.d mde/input/Input.d mde/mde.d mde/setup/init2.d mde/setup/paths.d test/mdeTest.d unittest/InputConfig.mtt
diffstat 11 files changed, 55 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 !<char[][]|Configs=["Default"]>
 {Default}
 <uint[][uint]|B=[ 0x8800001B : [[0x1000, 0x0]] ]>
-{UnitTest}
-<uint[][uint]|B=[
-	0x88000124 : [[0x1000, 0x00F0]],
-	0x40000003 : [[0x1000, 0x01F0]],
-	0x20002005 : [ [0x1000,0x02F0],[0x1000,0x03F0] ],
-	0x110D600C : [[0x1000,0x04F0]],
-	0x120D600C : [[0x1000,0x05F0]],
-	0x140D600C : [[0x1000,0x06F0]],
-	0x180D600C : [[0x1000,0x07F0]] ]>
-<uint[][uint]|A=[0x80001008 : [[0x1000,0x20F0]],0x130D600C : [[0x1000,0x21F0]] , 0x1C0D600C : [[0x1000,0x22F0]]]>
-<uint[][uint]|M=[ 0x88000000 : [[0x1000, 0x10F0], [0x1000, 0x11F0]], 0x40016064:[[0x1000,0x12F0]]]>
--- 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.
--- 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.
--- 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
-}
--- 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;
         }
         
--- 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]
--- 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();
--- 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) {
--- 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);
--- 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 <http://www.gnu.org/licenses/>. */
-
-/** 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.");
-}
--- /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}
+<uint[][uint]|B=[
+	0x88000124 : [[0x1000, 0x00F0]],
+	0x40000003 : [[0x1000, 0x01F0]],
+	0x20002005 : [ [0x1000,0x02F0],[0x1000,0x03F0] ],
+	0x110D600C : [[0x1000,0x04F0]],
+	0x120D600C : [[0x1000,0x05F0]],
+	0x140D600C : [[0x1000,0x06F0]],
+	0x180D600C : [[0x1000,0x07F0]] ]>
+<uint[][uint]|A=[0x80001008 : [[0x1000,0x20F0]],0x130D600C : [[0x1000,0x21F0]] , 0x1C0D600C : [[0x1000,0x22F0]]]>
+<uint[][uint]|M=[ 0x88000000 : [[0x1000, 0x10F0], [0x1000, 0x11F0]], 0x40016064:[[0x1000,0x12F0]]]>