Changeset 7669

Show
Ignore:
Timestamp:
03/19/07 03:28:53 (22 months ago)
Author:
alex
Message:

try harder to get function-only test names, add a minimal test file for the bootstrap, and ensure that test harness self-tests aren't run all the time. Refs #2500

Location:
dojo/trunk/tests
Files:
3 added
2 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/tests/runner.js

    r7650 r7669  
    1313// Utility Functions and Classes 
    1414// 
     15 
     16tests.selfTest = false; 
    1517 
    1618tests.hitch = function(/*Object*/thisObject, /*Function|String*/method /*, ...*/){ 
     
    374376                }else{ 
    375377                        try{ 
    376                                 tests.debug(tObj.runTest.toSource()); 
     378                                var fStr = "function "; 
     379                                var ts = tObj.runTest+""; 
     380                                if(0 == ts.indexOf(fStr)){ 
     381                                        tObj.name = ts.split(fStr)[1].split("(", 1)[0]; 
     382                                } 
     383                                // tests.debug(tObj.runTest.toSource()); 
    377384                        }catch(e){ 
    378385                        } 
  • dojo/trunk/tests/_base.js

    r7653 r7669  
    88// the end 
    99 
     10if(tests.selfTest){ 
    1011 
    11 tests.register("tests.smokeTest",  
    12         [ 
    13                 function sanityCheckHarness(t){ 
    14                         // sanity checks 
    15                         t.assertTrue(true); 
    16                         t.assertFalse(false); 
    17                         t.assertFalse(0); 
    18                         t.assertFalse(null); 
    19                         var tObj = { w00t: false, blarg: true }; 
    20                         t.assertEqual( 
    21                                 ["thinger", "blah", tObj],  
    22                                 ["thinger", "blah", tObj] 
    23                         ); 
    24                         t.assertEqual(tObj, tObj); 
    25                 }, 
    26                 /* 
    27                 // uncomment to tests exception handling 
    28                 function sanityCheckassertTrue(t){ 
    29                         // should throw an error 
    30                         t.assertTrue(false); 
    31                 }, 
    32                 function sanityCheckassertFalse(t){ 
    33                         // should throw an error 
    34                         t.assertFalse(true); 
    35                 }, 
    36                 function sanityCheckassertEqual(t){ 
    37                         // should throw an error 
    38                         t.assertEqual("foo", "bar"); 
    39                 }, 
    40                 */ 
    41                 { 
    42                         name: "eqTest", 
    43                         // smoke test the fixture system 
    44                         setUp: function(t){ 
    45                                 this.foo = "blah"; 
     12        tests.register("tests.smokeTest",  
     13                [ 
     14                        function sanityCheckHarness(t){ 
     15                                // sanity checks 
     16                                t.assertTrue(true); 
     17                                t.assertFalse(false); 
     18                                t.assertFalse(0); 
     19                                t.assertFalse(null); 
     20                                var tObj = { w00t: false, blarg: true }; 
     21                                t.assertEqual( 
     22                                        ["thinger", "blah", tObj],  
     23                                        ["thinger", "blah", tObj] 
     24                                ); 
     25                                t.assertEqual(tObj, tObj); 
    4626                        }, 
    47                         runTest: function(t){ 
    48                                 t.assertEqual("blah", this.foo); 
     27                        /* 
     28                        // uncomment to tests exception handling 
     29                        function sanityCheckassertTrue(t){ 
     30                                // should throw an error 
     31                                t.assertTrue(false); 
    4932                        }, 
    50                         tearDown: function(t){ 
    51                         } 
    52                 } 
    53         ] 
    54 ); 
    55  
    56 if(testGlobal["dojo"]){ 
    57         tests.register("tests._base",  
    58                 [ 
    59                         function dojoIsAvailable(t){ 
    60                                 t.assertTrue(testGlobal["dojo"]); 
    61                         } 
    62                 ] 
    63         ); 
    64 } 
    65  
    66 if(testGlobal["setTimeout"]){ 
    67         // a stone-stupid async test 
    68         tests.register("tests.async",  
    69                 [ 
     33                        function sanityCheckassertFalse(t){ 
     34                                // should throw an error 
     35                                t.assertFalse(true); 
     36                        }, 
     37                        function sanityCheckassertEqual(t){ 
     38                                // should throw an error 
     39                                t.assertEqual("foo", "bar"); 
     40                        }, 
     41                        */ 
    7042                        { 
    71                                 name: "deferredSuccess", 
     43                                name: "eqTest", 
     44                                // smoke test the fixture system 
     45                                setUp: function(t){ 
     46                                        this.foo = "blah"; 
     47                                }, 
    7248                                runTest: function(t){ 
    73                                         var d = new tests.Deferred(); 
    74                                         setTimeout(d.getTestCallback(function(){ 
    75                                                 t.assertTrue(true); 
    76                                                 t.assertFalse(false); 
    77                                         }), 50); 
    78                                         return d; 
    79                                 } 
    80                         }, 
    81                         { 
    82                                 name: "deferredFailure", 
    83                                 runTest: function(t){ 
    84                                         var d = new tests.Deferred(); 
    85                                         setTimeout(function(){ 
    86                                                 d.errback(new Error("hrm...")); 
    87                                         }, 50); 
    88                                         return d; 
    89                                 } 
    90                         }, 
    91                         { 
    92                                 name: "timeoutFailure", 
    93                                 timeout: 50, 
    94                                 runTest: function(t){ 
    95                                         // timeout of 50 
    96                                         var d = new tests.Deferred(); 
    97                                         setTimeout(function(){ 
    98                                                 d.callback(true); 
    99                                         }, 100); 
    100                                         return d; 
     49                                        t.assertEqual("blah", this.foo); 
     50                                }, 
     51                                tearDown: function(t){ 
    10152                                } 
    10253                        } 
    10354                ] 
    10455        ); 
     56 
     57        if(testGlobal["dojo"]){ 
     58                tests.register("tests._base",  
     59                        [ 
     60                                function dojoIsAvailable(t){ 
     61                                        t.assertTrue(testGlobal["dojo"]); 
     62                                } 
     63                        ] 
     64                ); 
     65        } 
     66 
     67        if(testGlobal["setTimeout"]){ 
     68                // a stone-stupid async test 
     69                tests.register("tests.async",  
     70                        [ 
     71                                { 
     72                                        name: "deferredSuccess", 
     73                                        runTest: function(t){ 
     74                                                var d = new tests.Deferred(); 
     75                                                setTimeout(d.getTestCallback(function(){ 
     76                                                        t.assertTrue(true); 
     77                                                        t.assertFalse(false); 
     78                                                }), 50); 
     79                                                return d; 
     80                                        } 
     81                                }, 
     82                                { 
     83                                        name: "deferredFailure", 
     84                                        runTest: function(t){ 
     85                                                var d = new tests.Deferred(); 
     86                                                setTimeout(function(){ 
     87                                                        d.errback(new Error("hrm...")); 
     88                                                }, 50); 
     89                                                return d; 
     90                                        } 
     91                                }, 
     92                                { 
     93                                        name: "timeoutFailure", 
     94                                        timeout: 50, 
     95                                        runTest: function(t){ 
     96                                                // timeout of 50 
     97                                                var d = new tests.Deferred(); 
     98                                                setTimeout(function(){ 
     99                                                        d.callback(true); 
     100                                                }, 100); 
     101                                                return d; 
     102                                        } 
     103                                } 
     104                        ] 
     105                ); 
     106        } 
    105107} 
     108 
     109try{ 
     110        // go grab the others 
     111        dojo.require("tests._base._loader.bootstrap"); 
     112        // FIXME: add test includes for the rest of the Dojo Base groups here 
     113}catch(e){ 
     114        tests.debug(e); 
     115} 
     116