subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1742832 - in /subversion/trunk/subversion/tests/cmdline: svnadmin_tests.py svndumpfilter_tests.py svntest/actions.py
Date Sun, 08 May 2016 15:03:11 GMT
Author: stefan2
Date: Sun May  8 15:03:11 2016
New Revision: 1742832

URL: http://svn.apache.org/viewvc?rev=1742832&view=rev
Log:
In our tests, load dump file consistently, i.e. as lists of byte strings
read from a binary file.

* subversion/tests/cmdline/svntest/actions.py
  (load_dumpfile): New utility function.

* subversion/tests/cmdline/svnadmin_tests.py
  (load_with_parent_dir,
   reflect_dropped_renumbered_revs,
   load_ranges,
   verify_denormalized_names,
   load_ignore_dates): Use the new function instead of inconsistent
                       copy/paste local code.

* subversion/tests/cmdline/svndumpfilter_tests.py
  (reflect_dropped_renumbered_revs,
   svndumpfilter_loses_mergeinfo,
   dumpfilter_with_targets,
   dumpfilter_with_patterns,
   match_empty_prefix,
   accepts_deltas,
   drop_all_empty_revisions): Same.

Modified:
    subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
    subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/actions.py

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1742832&r1=1742831&r2=1742832&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Sun May  8 15:03:11 2016
@@ -1033,7 +1033,7 @@ def load_with_parent_dir(sbox):
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svnadmin_tests_data',
                                    'mergeinfo_included.dump')
-  dumpfile = open(dumpfile_location).read()
+  dumpfile = svntest.actions.load_dumpfile(dumpfile_location)
 
   # Create 'sample' dir in sbox.repo_url, and load the dump stream there.
   svntest.actions.run_and_verify_svn(['Committing transaction...\n',
@@ -1125,7 +1125,7 @@ def reflect_dropped_renumbered_revs(sbox
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'with_merges.dump')
-  dumpfile = open(dumpfile_location).read()
+  dumpfile = svntest.actions.load_dumpfile(dumpfile_location)
 
   # Create 'toplevel' dir in sbox.repo_url
   svntest.actions.run_and_verify_svn(['Committing transaction...\n',
@@ -1363,9 +1363,10 @@ def dont_drop_valid_mergeinfo_during_inc
   #   Properties on 'branches/B2':
   #     svn:mergeinfo
   #       /trunk:9
-  dumpfile_full = open(os.path.join(os.path.dirname(sys.argv[0]),
-                                    'svnadmin_tests_data',
-                                    'mergeinfo_included_full.dump')).read()
+  dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
+                                   'svnadmin_tests_data',
+                                   'mergeinfo_included_full.dump')
+  dumpfile_full = svntest.actions.load_dumpfile(dumpfile_location)
   load_dumpstream(sbox, dumpfile_full, '--ignore-uuid')
 
   # Check that the mergeinfo is as expected.
@@ -1408,9 +1409,12 @@ def dont_drop_valid_mergeinfo_during_inc
   sbox.build(empty=True)
 
   # Load the three incremental dump files in sequence.
-  load_dumpstream(sbox, open(dump_file_r1_10).read(), '--ignore-uuid')
-  load_dumpstream(sbox, open(dump_file_r11_13).read(), '--ignore-uuid')
-  load_dumpstream(sbox, open(dump_file_r14_15).read(), '--ignore-uuid')
+  load_dumpstream(sbox, svntest.actions.load_dumpfile(dump_file_r1_10),
+                  '--ignore-uuid')
+  load_dumpstream(sbox, svntest.actions.load_dumpfile(dump_file_r11_13),
+                  '--ignore-uuid')
+  load_dumpstream(sbox, svntest.actions.load_dumpfile(dump_file_r14_15),
+                  '--ignore-uuid')
 
   # Check the mergeinfo, we use the same expected output as before,
   # as it (duh!) should be exactly the same as when we loaded the
@@ -1436,9 +1440,10 @@ def dont_drop_valid_mergeinfo_during_inc
   #     Project-Z     (Added r5)
   #     docs/         (Added r6)
   #       README      (Added r6)
-  dumpfile_skeleton = open(os.path.join(os.path.dirname(sys.argv[0]),
-                                        'svnadmin_tests_data',
-                                        'skeleton_repos.dump')).read()
+  dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
+                                                   'svnadmin_tests_data',
+                                                   'skeleton_repos.dump')
+  dumpfile_skeleton = svntest.actions.load_dumpfile(dumpfile_location)
   load_dumpstream(sbox, dumpfile_skeleton, '--ignore-uuid')
 
   # Load 'svnadmin_tests_data/mergeinfo_included_full.dump' in one shot:
@@ -1482,11 +1487,11 @@ def dont_drop_valid_mergeinfo_during_inc
   load_dumpstream(sbox, dumpfile_skeleton, '--ignore-uuid')
 
   # Load the three incremental dump files in sequence.
-  load_dumpstream(sbox, open(dump_file_r1_10).read(),
+  load_dumpstream(sbox, svntest.actions.load_dumpfile(dump_file_r1_10),
                   '--parent-dir', 'Projects/Project-X', '--ignore-uuid')
-  load_dumpstream(sbox, open(dump_file_r11_13).read(),
+  load_dumpstream(sbox, svntest.actions.load_dumpfile(dump_file_r11_13),
                   '--parent-dir', 'Projects/Project-X', '--ignore-uuid')
-  load_dumpstream(sbox, open(dump_file_r14_15).read(),
+  load_dumpstream(sbox, svntest.actions.load_dumpfile(dump_file_r14_15),
                   '--parent-dir', 'Projects/Project-X', '--ignore-uuid')
 
   # Check the resulting mergeinfo.  We expect the exact same results
@@ -1778,7 +1783,7 @@ def load_ranges(sbox):
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svnadmin_tests_data',
                                    'skeleton_repos.dump')
-  dumplines = open(dumpfile_location).readlines()
+  dumplines = svntest.actions.load_dumpfile(dumpfile_location)
   dumpdata = "".join(dumplines)
 
   # Load our dumpfile, 2 revisions at a time, verifying that we have
@@ -2473,7 +2478,7 @@ def verify_denormalized_names(sbox):
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svnadmin_tests_data',
                                    'normalization_check.dump')
-  load_dumpstream(sbox, open(dumpfile_location).read())
+  load_dumpstream(sbox, svntest.actions.load_dumpfile(dumpfile_location))
 
   exit_code, output, errput = svntest.main.run_svnadmin(
     "verify", "--check-normalization", sbox.repo_dir)
@@ -2551,9 +2556,10 @@ def load_ignore_dates(sbox):
 
   sbox.build(create_wc=False, empty=True)
 
-  dumpfile_skeleton = open(os.path.join(os.path.dirname(sys.argv[0]),
-                                        'svnadmin_tests_data',
-                                        'skeleton_repos.dump')).read()
+  dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
+                                                   'svnadmin_tests_data',
+                                                   'skeleton_repos.dump')
+  dumpfile_skeleton = svntest.actions.load_dumpfile(dumpfile_location)
 
   load_dumpstream(sbox, dumpfile_skeleton, '--ignore-dates')
   svntest.actions.run_and_verify_svnlook(['6\n'],

Modified: subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py?rev=1742832&r1=1742831&r2=1742832&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svndumpfilter_tests.py Sun May  8 15:03:11 2016
@@ -90,7 +90,7 @@ def reflect_dropped_renumbered_revs(sbox
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'with_merges.dump')
-  dumpfile = open(dumpfile_location).read()
+  dumpfile = svntest.actions.load_dumpfile(dumpfile_location)
 
   filtered_out, filtered_err = filter_and_return_output(
       dumpfile, 0, "include",
@@ -140,7 +140,7 @@ def svndumpfilter_loses_mergeinfo(sbox):
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'with_merges.dump')
-  dumpfile = open(dumpfile_location).read()
+  dumpfile = svntest.actions.load_dumpfile(dumpfile_location)
 
   filtered_out, filtered_err = filter_and_return_output(dumpfile, 0, "include",
                                                         "trunk", "branch1",
@@ -224,7 +224,7 @@ def dumpfilter_with_targets(sbox):
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'greek_tree.dump')
-  dumpfile = open(dumpfile_location).read()
+  dumpfile = svntest.actions.load_dumpfile(dumpfile_location)
 
   (fd, targets_file) = tempfile.mkstemp(dir=svntest.main.temp_dir)
   try:
@@ -247,7 +247,7 @@ def dumpfilter_with_patterns(sbox):
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'greek_tree.dump')
-  dumpfile = open(dumpfile_location).read()
+  dumpfile = svntest.actions.load_dumpfile(dumpfile_location)
   _simple_dumpfilter_test(sbox, dumpfile,
                           'exclude', '--pattern', '/A/D/[GH]*', '/A/[B]/E*')
 
@@ -335,7 +335,7 @@ def filter_mergeinfo_revs_outside_of_dum
   partial_dump = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'mergeinfo_included_partial.dump')
-  partial_dump_contents = open(partial_dump).read()
+  partial_dump_contents = svntest.actions.load_dumpfile(partial_dump)
   filtered_dumpfile2, filtered_out = filter_and_return_output(
       partial_dump_contents,
       8192, # Set a sufficiently large bufsize to avoid a deadlock
@@ -366,14 +366,15 @@ def filter_mergeinfo_revs_outside_of_dum
   #     docs/         (Added r6)
   #       README      (Added r6).
   sbox.build(empty=True)
-  skeleton_dumpfile = open(os.path.join(os.path.dirname(sys.argv[0]),
-                                        'svnadmin_tests_data',
-                                        'skeleton_repos.dump')).read()
+  skeleton_location = os.path.join(os.path.dirname(sys.argv[0]),
+                                                  'svnadmin_tests_data',
+                                                  'skeleton_repos.dump')
+  skeleton_dumpfile = svntest.actions.load_dumpfile(skeleton_location)
   load_dumpstream(sbox, skeleton_dumpfile, '--ignore-uuid')
   partial_dump2 = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'mergeinfo_included_partial.dump')
-  partial_dump_contents2 = open(partial_dump2).read()
+  partial_dump_contents2 = svntest.actions.load_dumpfile(partial_dump2)
   # Now use the partial dump file we used above, but this time exclude
   # the B2 branch.  Load the filtered dump into the /Projects/Project-X
   # subtree of the skeleton repos.
@@ -550,7 +551,7 @@ def dropped_but_not_renumbered_empty_rev
   full_dump = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svnadmin_tests_data',
                                    'mergeinfo_included_full.dump')
-  full_dump_contents = open(full_dump).read()
+  full_dump_contents = svntest.actions.load_dumpfile(full_dump)
   filtered_dumpfile, filtered_out = filter_and_return_output(
       full_dump_contents,
       16384, # Set a sufficiently large bufsize to avoid a deadlock
@@ -595,7 +596,7 @@ def match_empty_prefix(sbox):
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'greek_tree.dump')
-  dumpfile = open(dumpfile_location).read()
+  dumpfile = svntest.actions.load_dumpfile(dumpfile_location)
 
   def test(sbox, dumpfile, *dumpargs):
     """Run svndumpfilter with DUMPFILE as the input lines, load
@@ -648,7 +649,7 @@ def accepts_deltas(sbox):
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'simple_v3.dump')
-  dump_in = open(dumpfile_location).read()
+  dump_in = svntest.actions.load_dumpfile(dumpfile_location)
 
   dump_out, err = filter_and_return_output(dump_in, 0, "include",
                                                         "trunk", "--quiet")
@@ -683,7 +684,7 @@ def dumpfilter_targets_expect_leading_sl
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'greek_tree.dump')
-  dumpfile = open(dumpfile_location).read()
+  dumpfile = svntest.actions.load_dumpfile(dumpfile_location)
 
   (fd, targets_file) = tempfile.mkstemp(dir=svntest.main.temp_dir)
   try:
@@ -706,7 +707,7 @@ def drop_all_empty_revisions(sbox):
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svndumpfilter_tests_data',
                                    'empty_revisions.dump')
-  dump_contents = open(dumpfile_location).read()
+  dump_contents = svntest.actions.load_dumpfile(dumpfile_location)
 
   filtered_dumpfile, filtered_err = filter_and_return_output(
       dump_contents,

Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1742832&r1=1742831&r2=1742832&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Sun May  8 15:03:11 2016
@@ -1937,6 +1937,10 @@ def get_wc_base_rev(wc_dir):
   "Return the BASE revision of the working copy at WC_DIR."
   return run_and_parse_info(wc_dir)[0]['Revision']
 
+def load_dumpfile(filename):
+  "Return the contents of the FILENAME assuming that it is a dump file"
+  return open(filename, "rb").readlines()
+
 def hook_failure_message(hook_name):
   """Return the error message that the client prints for failure of the
   specified hook HOOK_NAME. The wording changed with Subversion 1.5."""



Mime
View raw message