Rev 5456: Add a new hidden ``test-script`` command. in file:///home/vila/src/bzr/experimental/test-script/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Oct 1 14:45:42 BST 2010


At file:///home/vila/src/bzr/experimental/test-script/

------------------------------------------------------------
revno: 5456
revision-id: v.ladeuil+lp at free.fr-20101001134542-0omhto426pxkpl1e
parent: pqm at pqm.ubuntu.com-20101001084939-b9q3wnz4duhz2v6y
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: test-script
timestamp: Fri 2010-10-01 15:45:42 +0200
message:
  Add a new hidden ``test-script`` command.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2010-10-01 08:49:39 +0000
+++ b/NEWS	2010-10-01 13:45:42 +0000
@@ -73,6 +73,9 @@
 * Fix tests that failed when run under ``LANG=C``.
   (Andrew Bennetts, #632387)
 
+* ``bzr test-script script`` is a new command that runs a shell-like script
+  from an the ``script`` file. (Vincent Ladeuil)
+
 * Use tests.TestCaseInTempDir for tests that requires disk resources.
   (Vincent Ladeuil, #650001)
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-10-01 08:49:39 +0000
+++ b/bzrlib/builtins.py	2010-10-01 13:45:42 +0000
@@ -6043,5 +6043,6 @@
         ('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
         ('cmd_conflicts', [], 'bzrlib.conflicts'),
         ('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
+        ('cmd_test_script', [], 'bzrlib.tests.script'),
         ]:
         builtin_command_registry.register_lazy(name, aliases, module_name)

=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py	2010-07-28 07:05:19 +0000
+++ b/bzrlib/tests/blackbox/__init__.py	2010-10-01 13:45:42 +0000
@@ -35,97 +35,100 @@
     # add the tests for this module
     suite.addTests(basic_tests)
 
+    prefix = 'bzrlib.tests.blackbox.'
     testmod_names = [
-                     'bzrlib.tests.blackbox.test_add',
-                     'bzrlib.tests.blackbox.test_added',
-                     'bzrlib.tests.blackbox.test_alias',
-                     'bzrlib.tests.blackbox.test_aliases',
-                     'bzrlib.tests.blackbox.test_ancestry',
-                     'bzrlib.tests.blackbox.test_annotate',
-                     'bzrlib.tests.blackbox.test_branch',
-                     'bzrlib.tests.blackbox.test_break_lock',
-                     'bzrlib.tests.blackbox.test_breakin',
-                     'bzrlib.tests.blackbox.test_bound_branches',
-                     'bzrlib.tests.blackbox.test_bundle_info',
-                     'bzrlib.tests.blackbox.test_cat',
-                     'bzrlib.tests.blackbox.test_cat_revision',
-                     'bzrlib.tests.blackbox.test_check',
-                     'bzrlib.tests.blackbox.test_checkout',
-                     'bzrlib.tests.blackbox.test_clean_tree',
-                     'bzrlib.tests.blackbox.test_command_encoding',
-                     'bzrlib.tests.blackbox.test_commit',
-                     'bzrlib.tests.blackbox.test_conflicts',
-                     'bzrlib.tests.blackbox.test_debug',
-                     'bzrlib.tests.blackbox.test_deleted',
-                     'bzrlib.tests.blackbox.test_diff',
-                     'bzrlib.tests.blackbox.test_dump_btree',
-                     'bzrlib.tests.blackbox.test_dpush',
-                     'bzrlib.tests.blackbox.test_exceptions',
-                     'bzrlib.tests.blackbox.test_export',
-                     'bzrlib.tests.blackbox.test_filesystem_cicp',
-                     'bzrlib.tests.blackbox.test_filtered_view_ops',
-                     'bzrlib.tests.blackbox.test_find_merge_base',
-                     'bzrlib.tests.blackbox.test_help',
-                     'bzrlib.tests.blackbox.test_hooks',
-                     'bzrlib.tests.blackbox.test_ignore',
-                     'bzrlib.tests.blackbox.test_ignored',
-                     'bzrlib.tests.blackbox.test_info',
-                     'bzrlib.tests.blackbox.test_init',
-                     'bzrlib.tests.blackbox.test_inventory',
-                     'bzrlib.tests.blackbox.test_join',
-                     'bzrlib.tests.blackbox.test_locale',
-                     'bzrlib.tests.blackbox.test_log',
-                     'bzrlib.tests.blackbox.test_logformats',
-                     'bzrlib.tests.blackbox.test_lookup_revision',
-                     'bzrlib.tests.blackbox.test_ls',
-                     'bzrlib.tests.blackbox.test_lsprof',
-                     'bzrlib.tests.blackbox.test_merge',
-                     'bzrlib.tests.blackbox.test_merge_directive',
-                     'bzrlib.tests.blackbox.test_missing',
-                     'bzrlib.tests.blackbox.test_modified',
-                     'bzrlib.tests.blackbox.test_mv',
-                     'bzrlib.tests.blackbox.test_nick',
-                     'bzrlib.tests.blackbox.test_non_ascii',
-                     'bzrlib.tests.blackbox.test_outside_wt',
-                     'bzrlib.tests.blackbox.test_pack',
-                     'bzrlib.tests.blackbox.test_pull',
-                     'bzrlib.tests.blackbox.test_push',
-                     'bzrlib.tests.blackbox.test_reconcile',
-                     'bzrlib.tests.blackbox.test_reconfigure',
-                     'bzrlib.tests.blackbox.test_reference',
-                     'bzrlib.tests.blackbox.test_remerge',
-                     'bzrlib.tests.blackbox.test_remove',
-                     'bzrlib.tests.blackbox.test_re_sign',
-                     'bzrlib.tests.blackbox.test_remove_tree',
-                     'bzrlib.tests.blackbox.test_revert',
-                     'bzrlib.tests.blackbox.test_revno',
-                     'bzrlib.tests.blackbox.test_revision_history',
-                     'bzrlib.tests.blackbox.test_revision_info',
-                     'bzrlib.tests.blackbox.test_rmbranch',
-                     'bzrlib.tests.blackbox.test_selftest',
-                     'bzrlib.tests.blackbox.test_send',
-                     'bzrlib.tests.blackbox.test_serve',
-                     'bzrlib.tests.blackbox.test_shared_repository',
-                     'bzrlib.tests.blackbox.test_shelve',
-                     'bzrlib.tests.blackbox.test_sign_my_commits',
-                     'bzrlib.tests.blackbox.test_split',
-                     'bzrlib.tests.blackbox.test_status',
-                     'bzrlib.tests.blackbox.test_switch',
-                     'bzrlib.tests.blackbox.test_tags',
-                     'bzrlib.tests.blackbox.test_testament',
-                     'bzrlib.tests.blackbox.test_too_much',
-                     'bzrlib.tests.blackbox.test_uncommit',
-                     'bzrlib.tests.blackbox.test_unknowns',
-                     'bzrlib.tests.blackbox.test_update',
-                     'bzrlib.tests.blackbox.test_upgrade',
-                     'bzrlib.tests.blackbox.test_version',
-                     'bzrlib.tests.blackbox.test_version_info',
-                     'bzrlib.tests.blackbox.test_versioning',
-                     'bzrlib.tests.blackbox.test_view',
-                     'bzrlib.tests.blackbox.test_whoami',
+                     'test_add',
+                     'test_added',
+                     'test_alias',
+                     'test_aliases',
+                     'test_ancestry',
+                     'test_annotate',
+                     'test_branch',
+                     'test_break_lock',
+                     'test_breakin',
+                     'test_bound_branches',
+                     'test_bundle_info',
+                     'test_cat',
+                     'test_cat_revision',
+                     'test_check',
+                     'test_checkout',
+                     'test_clean_tree',
+                     'test_command_encoding',
+                     'test_commit',
+                     'test_conflicts',
+                     'test_debug',
+                     'test_deleted',
+                     'test_diff',
+                     'test_dump_btree',
+                     'test_dpush',
+                     'test_exceptions',
+                     'test_export',
+                     'test_filesystem_cicp',
+                     'test_filtered_view_ops',
+                     'test_find_merge_base',
+                     'test_help',
+                     'test_hooks',
+                     'test_ignore',
+                     'test_ignored',
+                     'test_info',
+                     'test_init',
+                     'test_inventory',
+                     'test_join',
+                     'test_locale',
+                     'test_log',
+                     'test_logformats',
+                     'test_lookup_revision',
+                     'test_ls',
+                     'test_lsprof',
+                     'test_merge',
+                     'test_merge_directive',
+                     'test_missing',
+                     'test_modified',
+                     'test_mv',
+                     'test_nick',
+                     'test_non_ascii',
+                     'test_outside_wt',
+                     'test_pack',
+                     'test_pull',
+                     'test_push',
+                     'test_reconcile',
+                     'test_reconfigure',
+                     'test_reference',
+                     'test_remerge',
+                     'test_remove',
+                     'test_re_sign',
+                     'test_remove_tree',
+                     'test_revert',
+                     'test_revno',
+                     'test_revision_history',
+                     'test_revision_info',
+                     'test_rmbranch',
+                     'test_script',
+                     'test_selftest',
+                     'test_send',
+                     'test_serve',
+                     'test_shared_repository',
+                     'test_shelve',
+                     'test_sign_my_commits',
+                     'test_split',
+                     'test_status',
+                     'test_switch',
+                     'test_tags',
+                     'test_testament',
+                     'test_too_much',
+                     'test_uncommit',
+                     'test_unknowns',
+                     'test_update',
+                     'test_upgrade',
+                     'test_version',
+                     'test_version_info',
+                     'test_versioning',
+                     'test_view',
+                     'test_whoami',
                      ]
     # add the tests for the sub modules
-    suite.addTests(loader.loadTestsFromModuleNames(testmod_names))
+    suite.addTests(loader.loadTestsFromModuleNames(
+            [prefix + module_name for module_name in testmod_names]))
     return suite
 
 

=== modified file 'bzrlib/tests/script.py'
--- a/bzrlib/tests/script.py	2010-09-13 08:14:44 +0000
+++ b/bzrlib/tests/script.py	2010-10-01 13:45:42 +0000
@@ -28,6 +28,8 @@
 from cStringIO import StringIO
 
 from bzrlib import (
+    commands,
+    errors,
     osutils,
     tests,
     )
@@ -501,3 +503,32 @@
 def run_script(test_case, script_string):
     """Run the given script within a testcase"""
     return ScriptRunner().run_script(test_case, script_string)
+
+
+class cmd_test_script(commands.Command):
+    """Run a shell-like test from a file."""
+
+    hidden = True
+    takes_args = ['infile']
+
+    @commands.display_command
+    def run(self, infile):
+
+        f = open(infile)
+        try:
+            script = f.read()
+        finally:
+            f.close()
+
+        class Test(TestCaseWithTransportAndScript):
+
+            script = None # Set before running
+
+            def test_it(self):
+                self.run_script(script)
+
+        runner = tests.TextTestRunner(stream=self.outf)
+        test = Test('test_it')
+        test.path = os.path.realpath(infile)
+        res = runner.run(test)
+        return len(res.errors) + len(res.failures)



More information about the bazaar-commits mailing list