[Pkg-javascript-commits] [tools.pkg-javascript.debian.org] 01/01: added first test

Leo Iannacone l3on-guest at moszumanska.debian.org
Sat May 10 15:31:07 UTC 2014


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

l3on-guest pushed a commit to branch master
in repository tools.pkg-javascript.debian.org.

commit 449b99cb775fd077a80c06139fe87b6bb0dcd389
Author: Leo Iannacone <l3on at ubuntu.com>
Date:   Sat May 10 17:29:39 2014 +0200

    added first test
---
 test-require-all-modules.py | 90 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/test-require-all-modules.py b/test-require-all-modules.py
new file mode 100755
index 0000000..6a18683
--- /dev/null
+++ b/test-require-all-modules.py
@@ -0,0 +1,90 @@
+#!/usr/bin/python
+"""
+Test if all node-module packages can be installed and
+works fine in nodejs.
+
+The test is:
+
+ nodejs -e "require('foo');"
+
+"""
+
+
+from commands import getstatusoutput
+import os
+
+
+BUG_TEMPLATE = """Package: %(name)s
+Severity: grave
+
+Dear maintainer,
+
+testing your module as:
+
+nodejs -e "require('%(name)s');"
+
+It fails and return:
+
+%(code)s
+
+"""
+
+
+def get_cmd_output(command):
+    info = getstatusoutput(command)
+    if info[0] != 0:
+        raise Exception(info[1])
+    return info[1]
+
+
+def report(what):
+    with open("test_report", 'a') as fd:
+        if what and what[-1] != "\n":
+            what += "\n"
+        fd.write(what)
+
+
+def test_package(package):
+    name = package.replace('node-', '')
+    formatted = "{0:7} - {1}"
+    result = ''
+    try:
+        get_cmd_output('apt-get install %s -y' % package)
+        get_cmd_output('nodejs -e "require(\'%s\');"' % name)
+        result = formatted.format("success", package)
+    except Exception as code:
+        with open("%s_bug.mail" % package, 'w') as fd:
+            args = {}
+            args["code"] = code
+            args["name"] = name
+            fd.write(BUG_TEMPLATE % args)
+        result = formatted.format("fail", package)
+    finally:
+        print result
+        report(result)
+        try:
+            get_cmd_output('apt-get remove %s -y' % package)
+            get_cmd_output('apt-get autoremove -y')
+        except:
+            pass
+
+
+def main():
+    dir_name = "test_require_reports"
+    if os.path.exists(dir_name):
+        print('A dir "%s" already exists. Exit.' % dir_name)
+        exit(1)
+    os.makedirs(dir_name)
+    os.chdir(dir_name)
+    packages = get_cmd_output("apt-cache search node | "
+                              "grep '^node-' | "
+                              "awk -F' - ' '{print $1}'")
+
+    packages = packages.split('\n')
+    for package in packages:
+        test_package(package)
+    os.chdir('..')
+
+
+if __name__ == '__main__':
+    main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/tools.pkg-javascript.debian.org.git



More information about the Pkg-javascript-commits mailing list