summaryrefslogtreecommitdiff
path: root/js/test/Common/Common.js
blob: 4b02ead96896c86e3027b990bdeb3477660287b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

(function(module, require, exports){   
    var Ice = require("Ice/Ice").Ice;

    var write = function(msg)
    {
        process.stdout.write(msg); 
    };

    var writeLine = function(msg)
    {
        this.write(msg + "\n");
    };
    
    var run = function(require)
    {
        var id = new Ice.InitializationData();
        id.properties = Ice.createProperties(process.argv);
        
        var test = require("./Client").__test__;
        
        test({write: write, writeLine: writeLine}, id).exception(
            function(ex, r)
            {
                console.log(ex.toString());
                if(r instanceof Ice.AsyncResult)
                {
                    console.log("\nexception occurred in call to " + r.operation);
                }
                if(ex.stack)
                {
                    console.log(ex.stack);
                }
                process.exit(1);
            });
    };

    exports.run = run;
}
(typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? module : undefined,
 typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? require : window.Ice.__require,
 typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? exports : window));