Ignore:
Timestamp:
Apr 24, 2015, 1:03:31 PM (9 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Imported latest envjasmine version, the initial import from darcs had the wrong version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyenvjasmine/envjasmine/lib/envjasmine.js

    r0 r19  
    4040};
    4141
     42EnvJasmine.printDebug = function(str) {
     43    if (EnvJasmine.debug) {
     44        print(str);
     45    }
     46}
     47
    4248EnvJasmine.normalizePath = function(path) {
    4349    var endsInSlash = (path.slice(-1) == "/");
     
    5965            EnvJasmine.cx.evaluateReader(scope, fileIn, normalizedPath, 0, null);
    6066        } catch (e) {
     67            print (e);
    6168            print('Could not read file: ' + normalizedPath );
    6269        } finally {
     
    8895};
    8996
     97EnvJasmine.setJsDir = function(jsDir) {
     98    EnvJasmine.jsDir = jsDir;
     99};
     100
    90101// Process command line options
    91 
    92102(function(argumentList) {
    93103    var arg, nameValue, spec = "", specLoc;
     
    97107    EnvJasmine.failedCount = 0;
    98108    EnvJasmine.totalCount = 0;
    99 
    100109    for (var i = 0; i < argumentList.length; i++) {
    101110        arg = argumentList[i];
    102 
    103111        if (arg.slice(0, 2) == "--") {
    104112            nameValue = arg.slice(2).split('=');
    105 
    106113            switch(nameValue[0]) {
    107114                case "testDir":
     
    112119                    EnvJasmine.setTestDir(nameValue[1]); // Set the root as the default testDir.
    113120                    break;
     121                case "jsDir":
     122                    EnvJasmine.setJsDir(nameValue[1]);
     123                    break;
    114124                case "environment":
    115125                    EnvJasmine.environment = nameValue[1];
     
    129139                case "customSpecsDir":
    130140                    EnvJasmine.customSpecsDir = nameValue[1];
     141                    break;
     142                case "plugin":
     143                    EnvJasmine.addPlugin(nameValue[1]);
     144                    break;
     145                case "debug":
     146                    EnvJasmine.debug = true;
    131147                    break;
    132148                case "help":
     
    196212EnvJasmine.results = [];
    197213
     214EnvJasmine.addFinallyFunction = function(f) {
     215    EnvJasmine.finallyFunctions.push(f);
     216};
     217EnvJasmine.finallyFunctions = [];
     218
     219
    198220EnvJasmine.loadConfig = function () {
    199221    EnvJasmine.loadGlobal(EnvJasmine.configFile);
    200222};
    201223
     224EnvJasmine.plugins = [];
     225EnvJasmine.addPlugin = function(path) {
     226    EnvJasmine.plugins.push(path);
     227};
     228
    202229(function() {
    203230    var i, fileIn, len;
    204231
    205232    EnvJasmine.loadConfig();
    206    
     233
     234    for (i = 0; i < EnvJasmine.plugins.length; i++) {
     235        EnvJasmine.loadGlobal(EnvJasmine.plugins[i]);
     236    }
     237
    207238    if (typeof EnvJasmine.reporterClass === "undefined") {
    208239        // Use the standard reporter
    209240        EnvJasmine.reporterClass = RhinoReporter;
    210241    }
    211    
     242
    212243
    213244    jasmine.getEnv().addReporter(new EnvJasmine.reporterClass());
     
    242273            EnvJasmine.cx.evaluateString(EnvJasmine.currentScope, 'window.location.assign(["file://", EnvJasmine.libDir, "envjasmine.html"].join(EnvJasmine.SEPARATOR));', 'Executing '+EnvJasmine.specs[i], 0, null);
    243274        }
     275        catch (e) {
     276            print("Problem opening " + EnvJasmine.specFile + ": " + e);
     277        }
    244278        finally {
    245             fileIn.close();
    246         }
     279            if(fileIn) {
     280                fileIn.close();
     281            }
     282        }
     283    }
     284
     285    for (i = 0; i < EnvJasmine.finallyFunctions.length; i++) {
     286        EnvJasmine.finallyFunctions[i]();
    247287    }
    248288
Note: See TracChangeset for help on using the changeset viewer.