summaryrefslogtreecommitdiff
path: root/tests/dh_xul-ext/test
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@ubuntu.com>2011-07-09 20:22:00 +0200
committerBenjamin Drung <bdrung@ubuntu.com>2011-07-09 20:22:00 +0200
commitc5178d7b50957a9f54f9bed8a6d7ccf081798118 (patch)
tree5a69ef5711c18b80607bcec84bc52ead63934450 /tests/dh_xul-ext/test
parentdf58f3a3d891a494232d6e49a5a1862a557e8930 (diff)
Add an --all parameter to dh_xul-ext to make packages that work with every
browser they can actually work with (Closes: #610499).
Diffstat (limited to 'tests/dh_xul-ext/test')
-rwxr-xr-xtests/dh_xul-ext/test78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/dh_xul-ext/test b/tests/dh_xul-ext/test
new file mode 100755
index 0000000..9936ca6
--- /dev/null
+++ b/tests/dh_xul-ext/test
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+
+# Copyright (c) 2011, Benjamin Drung <bdrung@debian.org>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+import os
+import sys
+import subprocess
+
+TESTS = ("all", "debian", "ubuntu")
+
+class TestError(Exception):
+ pass
+
+def escape_arg(arg):
+ "Shell-escpae arg, if necessary"
+ if ' ' not in arg:
+ return arg
+ return '"%s"' % arg.replace('\\', r'\\').replace('"', r'\"')
+
+def fail(message):
+ print >> sys.stderr, "dh_xul-ext test error: " + message
+ sys.exit(1)
+
+def check_call(cmd, cwd=None):
+ return_code = subprocess.call(cmd, cwd=cwd)
+ if return_code != 0:
+ raise TestError("'" + " ".join(escape_arg(cmd)) + "' returned " +
+ str(return_code) + ".")
+
+def compare_files(file1, file2):
+ actual = open(file1).read().strip()
+ expected = open(file2).read().strip()
+ if actual != expected:
+ raise TestError("Actual substvars files differs from expected file.\n"
+ "Expected content:\n" + expected + "\n" + \
+ "Actual content:\n" + actual)
+
+def test_dh_xul_ext(test):
+ basedir = os.path.dirname(__file__)
+ testdir = os.path.join(basedir, test)
+ clean_cmd = ["fakeroot", "debian/rules", "clean"]
+ check_call(clean_cmd, cwd=testdir)
+ try:
+ cmd = ["fakeroot", "debian/rules", "install"]
+ check_call(cmd, cwd=testdir)
+ substvars = os.path.join(testdir, "debian",
+ "xul-ext-test-package.substvars")
+ expected = os.path.join(basedir, "expected_result", test + ".substvars")
+ compare_files(substvars, expected)
+ finally:
+ check_call(clean_cmd, cwd=testdir)
+
+def main():
+ errors = 0
+ for test in TESTS:
+ try:
+ test_dh_xul_ext(test)
+ except TestError, error:
+ errors += 1
+ print >> sys.stderr, "dh_xul-ext error in " + test + " test: " + \
+ str(error)
+ if errors > 0:
+ sys.exit(1)
+
+if __name__ == "__main__":
+ main()