[tor-commits] [flashproxy/master] run flashproxy-test.js using nodejs instead of rhino. it is much quicker and doesn't require a JVM.

infinity0 at torproject.org infinity0 at torproject.org
Sat Jan 18 00:32:30 UTC 2014


commit aa66587104addced0bd40918e8108011c8cd5c8b
Author: Ximin Luo <infinity0 at gmx.com>
Date:   Fri Jan 17 22:56:59 2014 +0000

    run flashproxy-test.js using nodejs instead of rhino. it is much quicker and doesn't require a JVM.
---
 proxy/flashproxy-test.js |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/proxy/flashproxy-test.js b/proxy/flashproxy-test.js
index a46ca2d..e004ee8 100755
--- a/proxy/flashproxy-test.js
+++ b/proxy/flashproxy-test.js
@@ -1,10 +1,9 @@
-#!/usr/bin/env rhino
+#!/usr/bin/env node
 
-/* To run this test program, install the Rhino JavaScript interpreter
-   (apt-get install rhino). */
+/* To run this test program, install nodejs (apt-get install nodejs). */
 
 var VERBOSE = false;
-if (arguments.indexOf("-v") >= 0)
+if (process.argv.indexOf("-v") >= 0)
     VERBOSE = true;
 
 var num_tests = 0;
@@ -13,7 +12,9 @@ var num_failed = 0;
 var window = {location: {search: "?"}};
 var document = {cookie: ""};
 
-load("flashproxy.js");
+var fs = require("fs");
+var data = fs.readFileSync("./flashproxy.js", "utf-8");
+eval(data);
 
 function objects_equal(a, b) {
     if ((a === null) != (b === null))
@@ -39,8 +40,8 @@ var top = true;
 function announce(test_name) {
     if (VERBOSE) {
         if (!top)
-            print();
-        print(test_name);
+            console.log();
+        console.log(test_name);
     }
     top = false;
 }
@@ -48,13 +49,13 @@ function announce(test_name) {
 function pass(test) {
     num_tests++;
     if (VERBOSE)
-        print("PASS " + repr(test));
+        console.log("PASS " + repr(test));
 }
 
 function fail(test, expected, actual) {
     num_tests++;
     num_failed++;
-    print("FAIL " + repr(test) + "  expected: " + repr(expected) + "  actual: " + repr(actual));
+    console.log("FAIL " + repr(test) + "  expected: " + repr(expected) + "  actual: " + repr(actual));
 }
 
 function test_build_url() {
@@ -354,6 +355,6 @@ test_lang_keys();
 test_have_websocket_binary_frames();
 
 if (num_failed == 0)
-    quit(0);
+    process.exit(0);
 else
-    quit(1);
+    process.exit(1);



More information about the tor-commits mailing list