[Pkg-mozext-commits] [adblock-plus] 302/464: Made tests work again

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 20:44:27 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 7170308a099a857e962fcc7d9951fe8362c3b560
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Fri Oct 12 14:45:44 2012 +0200

    Made tests work again
---
 .hgignore                                   |  2 ++
 abp_rewrite.py                              | 33 ++------------------
 autotest.py                                 | 47 +++++++++++++++++++++++++++++
 autotest/test_abprewrite.js                 |  2 +-
 autotest/test_abprewrite.js.expected        |  5 ++-
 autotest/test_abprewrite_module.js          |  2 +-
 autotest/test_abprewrite_module.js.expected |  5 ++-
 autotest/test_comments.js                   |  2 +-
 autotest/test_globals.js                    |  2 +-
 autotest/test_trueast.js                    |  2 +-
 check.py                                    | 19 ------------
 fake_js.sh                                  |  3 --
 utils.py                                    | 37 +++++++++++++++++++++++
 13 files changed, 97 insertions(+), 64 deletions(-)

diff --git a/.hgignore b/.hgignore
index 7db5146..b832647 100644
--- a/.hgignore
+++ b/.hgignore
@@ -1,2 +1,4 @@
 ^mozilla/
 ^jstest/
+
+\.pyc$
diff --git a/abp_rewrite.py b/abp_rewrite.py
index eb6e38e..e599fa8 100644
--- a/abp_rewrite.py
+++ b/abp_rewrite.py
@@ -5,37 +5,8 @@
 # version 2.0 (the "License"). You can obtain a copy of the License at
 # http://mozilla.org/MPL/2.0/.
 
-import sys, os, subprocess, urllib, zipfile
-from StringIO import StringIO
-
-def ensureJSShell(basedir):
-  shell_dir = os.path.join(basedir, 'mozilla')
-  if not os.path.exists(shell_dir):
-    os.makedirs(shell_dir)
-  if sys.platform == 'win32':
-    path = os.path.join(shell_dir, 'js.exe')
-  else:
-    path = os.path.join(shell_dir, 'js')
-  if os.path.exists(path):
-    return path
-
-  platform_map = {
-    'win32': 'win32',
-    'linux2': 'linux-i686',
-    'darwin': 'mac',
-  }
-  if sys.platform not in platform_map:
-    raise Exception('Unknown platform, is there a JS shell version for it?')
-
-  download_url = 'http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/16.0.1-candidates/build1/jsshell-%s.zip' % platform_map[sys.platform]
-  data = StringIO(urllib.urlopen(download_url).read())
-  zip = zipfile.ZipFile(data)
-  zip.extractall(shell_dir)
-  zip.close()
-
-  if not os.path.exists(path):
-    raise Exception('Downloaded package didn\'t contain JS shell executable')
-  return path
+import sys, os, subprocess
+from utils import ensureJSShell
 
 def doRewrite():
   if len(sys.argv) < 4:
diff --git a/autotest.py b/autotest.py
new file mode 100644
index 0000000..d09cdef
--- /dev/null
+++ b/autotest.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# coding: utf-8
+
+# This Source Code is subject to the terms of the Mozilla Public License
+# version 2.0 (the "License"). You can obtain a copy of the License at
+# http://mozilla.org/MPL/2.0/.
+
+import sys, os, subprocess, re
+from utils import ensureJSShell
+
+def run_tests():
+  basedir = os.path.dirname(sys.argv[0])
+  if not basedir:
+    basedir = '.'
+
+  application = ensureJSShell(basedir)
+  testdir = os.path.join(basedir, 'autotest')
+  for file in os.listdir(testdir):
+    if not re.search(r'^test_.*\.js$', file):
+      continue
+
+    file = os.path.join(testdir, file)
+    handle = open(file, 'r')
+    name = None
+    arguments = None
+    for line in handle:
+      match = re.search(r'^//\s*([A-Za-z]+):\s*(.*?)\s*$', line)
+      if match and match.group(1).lower() == 'name':
+        name = match.group(2)
+      elif match and match.group(1).lower() == 'arguments':
+        arguments = match.group(2).split(' ')
+    handle.close()
+
+    if arguments == None:
+      continue
+
+    command = [application, os.path.join(basedir, 'jshydra.js'), file] + arguments
+    out = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].replace('\r', '')
+    expected = open(file + '.expected', 'r').read().replace('\r', '')
+    if out == expected:
+      print '%s passed' % name
+    else:
+      print '%s failed! Log:' % name
+      print out
+
+if __name__ == '__main__':
+  run_tests()
diff --git a/autotest/test_abprewrite.js b/autotest/test_abprewrite.js
index 82f04ed..200b525 100644
--- a/autotest/test_abprewrite.js
+++ b/autotest/test_abprewrite.js
@@ -1,4 +1,4 @@
-// Arguments: --trueast abprewrite_source.js
+// Arguments: --trueast autotest/abprewrite_source.js
 // Name: ABP rewriting test
 
 include("../scripts/abprewrite.js");
diff --git a/autotest/test_abprewrite.js.expected b/autotest/test_abprewrite.js.expected
index 06d9810..f43d613 100644
--- a/autotest/test_abprewrite.js.expected
+++ b/autotest/test_abprewrite.js.expected
@@ -9,7 +9,6 @@
 // source code. DO NOT MODIFY, change the original source code instead.
 //
 // Relevant repositories:
-// * https://hg.adblockplus.org/adblockplus/
 // * https://hg.adblockplus.org/jshydra/
 //
 
@@ -89,11 +88,11 @@ for (var a in b)
   foo();
 }
 for (var a in b){}
-while (a==b)
+while (a == b)
 {
   foo();
 }
-while (a==b){}
+while (a == b){}
 
 function genFunc()
 {
diff --git a/autotest/test_abprewrite_module.js b/autotest/test_abprewrite_module.js
index cffa681..224ba22 100644
--- a/autotest/test_abprewrite_module.js
+++ b/autotest/test_abprewrite_module.js
@@ -1,4 +1,4 @@
-// Arguments: --trueast --arg module=true abprewrite_source.js
+// Arguments: --trueast --arg module=true autotest/abprewrite_source.js
 // Name: ABP module rewriting test
 
 include("../scripts/abprewrite.js");
diff --git a/autotest/test_abprewrite_module.js.expected b/autotest/test_abprewrite_module.js.expected
index 55ef609..7c2e6f6 100644
--- a/autotest/test_abprewrite_module.js.expected
+++ b/autotest/test_abprewrite_module.js.expected
@@ -9,7 +9,6 @@
 // source code. DO NOT MODIFY, change the original source code instead.
 //
 // Relevant repositories:
-// * https://hg.adblockplus.org/adblockplus/
 // * https://hg.adblockplus.org/jshydra/
 //
 
@@ -92,11 +91,11 @@ require.scopes["abprewrite_source"] = (function()
     foo();
   }
   for (var a in b){}
-  while (a==b)
+  while (a == b)
   {
     foo();
   }
-  while (a==b){}
+  while (a == b){}
 
   function genFunc()
   {
diff --git a/autotest/test_comments.js b/autotest/test_comments.js
index 80c21e9..2eb0873 100644
--- a/autotest/test_comments.js
+++ b/autotest/test_comments.js
@@ -1,4 +1,4 @@
-// Arguments: test_comments.js
+// Arguments: autotest/test_comments.js
 // Name: Comment association test
 
 // This comment is associated with only code, so I don't see this.
diff --git a/autotest/test_globals.js b/autotest/test_globals.js
index c06739c..5bad540 100644
--- a/autotest/test_globals.js
+++ b/autotest/test_globals.js
@@ -1,4 +1,4 @@
-// Arguments: test_globals.js
+// Arguments: autotest/test_globals.js
 // Name: Global information test
 
 include("../utils/cleanast.js");
diff --git a/autotest/test_trueast.js b/autotest/test_trueast.js
index b427e84..c5e0407 100644
--- a/autotest/test_trueast.js
+++ b/autotest/test_trueast.js
@@ -1,4 +1,4 @@
-// Arguments: test_trueast.js
+// Arguments: autotest/test_trueast.js
 // Name: Simple asts
 
 include("../utils/astml.js");
diff --git a/check.py b/check.py
deleted file mode 100644
index 4c4bdb5..0000000
--- a/check.py
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/python
-
-banned = ["js1_5/Regress/regress-31255.js",
-	"js1_5/Regress/regress-351515.js",
-	"js1_5/Regress/regress-89443.js",
-	"js1_5/Regress/regress-98901.js",
-	"js1_8/regress/regress-366941.js",
-	"js1_8/regress/regress-459185.js",
-	"js1_8_1/regress/regress-452498-052.js",
-	"js1_8_1/regress/regress-452498-053.js",
-	"js1_8_1/regress/regress-452498-098.js",
-	"js1_8_1/regress/regress-452498-117.js"]
-
-import manifest
-xul_tester = manifest.NullXULInfoTester()
-test_list = manifest.parse('jstests.list', xul_tester)
-for test in test_list:
-	if test.enable and test.path[-5:] != '-n.js' and test.path not in banned:
-		print test.path
diff --git a/fake_js.sh b/fake_js.sh
deleted file mode 100755
index 9f7fb2c..0000000
--- a/fake_js.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-/src/build/trunk/mail/mozilla/js/src/js "$@"
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000..950e7d5
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,37 @@
+# coding: utf-8
+
+# This Source Code is subject to the terms of the Mozilla Public License
+# version 2.0 (the "License"). You can obtain a copy of the License at
+# http://mozilla.org/MPL/2.0/.
+
+import sys, os, urllib, zipfile
+from StringIO import StringIO
+
+def ensureJSShell(basedir):
+  shell_dir = os.path.join(basedir, 'mozilla')
+  if not os.path.exists(shell_dir):
+    os.makedirs(shell_dir)
+  if sys.platform == 'win32':
+    path = os.path.join(shell_dir, 'js.exe')
+  else:
+    path = os.path.join(shell_dir, 'js')
+  if os.path.exists(path):
+    return path
+
+  platform_map = {
+    'win32': 'win32',
+    'linux2': 'linux-i686',
+    'darwin': 'mac',
+  }
+  if sys.platform not in platform_map:
+    raise Exception('Unknown platform, is there a JS shell version for it?')
+
+  download_url = 'http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/16.0.1-candidates/build1/jsshell-%s.zip' % platform_map[sys.platform]
+  data = StringIO(urllib.urlopen(download_url).read())
+  zip = zipfile.ZipFile(data)
+  zip.extractall(shell_dir)
+  zip.close()
+
+  if not os.path.exists(path):
+    raise Exception('Downloaded package didn\'t contain JS shell executable')
+  return path

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list