Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | package; |
| 21 | |
| 22 | import org.apache.thrift.*; |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 23 | import org.apache.thrift.meta_data.*; |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 24 | import org.apache.thrift.protocol.*; |
| 25 | import org.apache.thrift.server.*; |
| 26 | import org.apache.thrift.transport.*; |
| 27 | import tests.ConstantsTest; |
| 28 | import tests.MultiplexTest; |
| 29 | import tests.StreamTest; |
| 30 | import thrift.test.*; |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 31 | |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 32 | enum WhatTests |
| 33 | { |
| 34 | Normal; |
| 35 | Multiplex; |
| 36 | Constants; |
Jens Geyer | e5ff9a8 | 2014-11-11 01:39:38 +0100 | [diff] [blame] | 37 | } |
| 38 | |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 39 | class Main |
| 40 | { |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 41 | static private var what : WhatTests = Normal; |
| 42 | static private var server : Bool = false; |
Jens Geyer | e5ff9a8 | 2014-11-11 01:39:38 +0100 | [diff] [blame] | 43 | |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 44 | 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 Geyer | e5ff9a8 | 2014-11-11 01:39:38 +0100 | [diff] [blame] | 50 | |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 51 | static private function ParseArgs() |
| 52 | { |
| 53 | #if sys |
Jens Geyer | e5ff9a8 | 2014-11-11 01:39:38 +0100 | [diff] [blame] | 54 | |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 55 | 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 Geyer | e5ff9a8 | 2014-11-11 01:39:38 +0100 | [diff] [blame] | 75 | |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 76 | #end |
| 77 | } |
Jens Geyer | e5ff9a8 | 2014-11-11 01:39:38 +0100 | [diff] [blame] | 78 | |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 79 | static public function main() |
| 80 | { |
| 81 | try |
| 82 | { |
| 83 | ParseArgs(); |
Jens Geyer | e5ff9a8 | 2014-11-11 01:39:38 +0100 | [diff] [blame] | 84 | |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 85 | 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 Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 100 | |
Jens Geyer | a420a24 | 2025-02-07 01:58:30 +0100 | [diff] [blame] | 101 | 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 Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 111 | } |