blob: 5e698396fd63552e2028ceeb9cfc975396309f57 [file] [log] [blame]
Jens Geyerfea00ac2014-10-01 02:22:48 +02001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20package;
21
22import org.apache.thrift.*;
Jens Geyerfea00ac2014-10-01 02:22:48 +020023import org.apache.thrift.meta_data.*;
Jens Geyera420a242025-02-07 01:58:30 +010024import org.apache.thrift.protocol.*;
25import org.apache.thrift.server.*;
26import org.apache.thrift.transport.*;
27import tests.ConstantsTest;
28import tests.MultiplexTest;
29import tests.StreamTest;
30import thrift.test.*;
Jens Geyerfea00ac2014-10-01 02:22:48 +020031
Jens Geyera420a242025-02-07 01:58:30 +010032enum WhatTests
33{
34 Normal;
35 Multiplex;
36 Constants;
Jens Geyere5ff9a82014-11-11 01:39:38 +010037}
38
Jens Geyerfea00ac2014-10-01 02:22:48 +020039class Main
40{
Jens Geyera420a242025-02-07 01:58:30 +010041 static private var what : WhatTests = Normal;
42 static private var server : Bool = false;
Jens Geyere5ff9a82014-11-11 01:39:38 +010043
Jens Geyera420a242025-02-07 01:58:30 +010044 static private inline var CMDLINEHELP : String
45 = "\nHaxeTests [client|server] [multiplex]\n"
46 + " client|server ... determines run mode for some tests, default is client\n"
47 + " multiplex ........ run multiplex test server or client\n"
48 + " constants ........ run constants and conformity tests\n"
49 ;
Jens Geyere5ff9a82014-11-11 01:39:38 +010050
Jens Geyera420a242025-02-07 01:58:30 +010051 static private function ParseArgs()
52 {
53 #if sys
Jens Geyere5ff9a82014-11-11 01:39:38 +010054
Jens Geyera420a242025-02-07 01:58:30 +010055 var args = Sys.args();
56 if ( args != null)
57 {
58 for ( arg in args)
59 {
60 switch (arg.toLowerCase())
61 {
62 case "client":
63 server = false;
64 case "server" :
65 server = true;
66 case "multiplex" :
67 what = Multiplex;
68 case "constants" :
69 what = Constants;
70 default:
71 throw 'Invalid argument "$arg"\n'+CMDLINEHELP;
72 }
73 }
74 }
Jens Geyere5ff9a82014-11-11 01:39:38 +010075
Jens Geyera420a242025-02-07 01:58:30 +010076 #end
77 }
Jens Geyere5ff9a82014-11-11 01:39:38 +010078
Jens Geyera420a242025-02-07 01:58:30 +010079 static public function main()
80 {
81 try
82 {
83 ParseArgs();
Jens Geyere5ff9a82014-11-11 01:39:38 +010084
Jens Geyera420a242025-02-07 01:58:30 +010085 switch ( what)
86 {
87 case Normal:
88 #if sys
89 tests.StreamTest.Run(server);
90 #end
91 case Multiplex:
92 #if ! (flash || html5 || js)
93 tests.MultiplexTest.Run(server);
94 #end
95 case Constants:
96 tests.ConstantsTest.Run(server);
97 default:
98 throw 'Unhandled test mode $what';
99 }
Jens Geyerb5028322014-11-09 02:38:11 +0100100
Jens Geyera420a242025-02-07 01:58:30 +0100101 trace("All tests completed.");
102 }
103 catch ( e: Dynamic)
104 {
105 trace('$e');
106 #if sys
107 Sys.exit(1); // indicate error
108 #end
109 }
110 }
Jens Geyerfea00ac2014-10-01 02:22:48 +0200111}