subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dan...@apache.org
Subject svn commit: r952586 - /subversion/trunk/subversion/tests/cmdline/diff_tests.py
Date Tue, 08 Jun 2010 09:26:51 GMT
Author: dannas
Date: Tue Jun  8 09:26:50 2010
New Revision: 952586

URL: http://svn.apache.org/viewvc?rev=952586&view=rev
Log:
Add url->wc test for creating 'git diffs'. At the same time, reformat the
existing test for wc-wc to use be able to display what lines are
differing instead of just returning a failure.

* subversion/tests/cmdline/diff_tests.py
  (make_git_diff_header): Add parameter 'src_label' and 'dst_label' for
    handling the special text on the form '(.../url_or_path) that is
    added to the diff label when we're contacting the repository for the
    diff.
  (diff_git_format): Rename to ..
  (diff_git_format_wc_wc): .. this and use run_and_verify_svn() for 
    checking output.
  (diff_git_format_url_wc): New test.
  (test_list): Update to incorporate the new tests.

Modified:
    subversion/trunk/subversion/tests/cmdline/diff_tests.py

Modified: subversion/trunk/subversion/tests/cmdline/diff_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/diff_tests.py?rev=952586&r1=952585&r2=952586&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/diff_tests.py Tue Jun  8 09:26:50 2010
@@ -52,17 +52,28 @@ def make_diff_header(path, old_tag, new_
     "+++ " + path_as_shown + "\t(" + new_tag + ")\n",
     ]
 
-def make_git_diff_header(path, old_tag, new_tag, add=False, delete=False,
-                         cp=False, mv=False, copyfrom=None):
+def make_git_diff_header(path, old_tag, new_tag, add=False, src_label=None,
+                         dst_label=None, delete=False, cp=False, mv=False, 
+                         copyfrom=None):
   """ Generate the expected 'git diff' header for file PATH, with its old
-  and new versions described in parentheses by OLD_TAG and NEW_TAG. ADD,
-  DELETE, CP and MV denotes the operations performed on the file. COPYFROM
-  is the source of a copy or move.  Return the header as an array of
-  newline-terminated strings."""
+  and new versions described in parentheses by OLD_TAG and NEW_TAG.
+  SRC_LABEL and DST_LABEL are paths or urls that are added to the diff
+  labels if we're diffing against the repository. ADD, DELETE, CP and MV
+  denotes the operations performed on the file. COPYFROM is the source of a
+  copy or move.  Return the header as an array of newline-terminated
+  strings."""
 
   path_as_shown = path.replace('\\', '/')
   if copyfrom:
     copyfrom_as_shown = copyfrom.replace('\\', '/')
+  if src_label:
+    src_label = '\t(.../' + src_label + ')'
+  else:
+    src_label = ''
+  if dst_label:
+    dst_label = '\t(.../' + dst_label + ')'
+  else:
+    dst_label = ''
 
   if add:
     return [
@@ -71,7 +82,7 @@ def make_git_diff_header(path, old_tag, 
       "diff --git a/" + path_as_shown + " b/" + path_as_shown + "\n",
       "new file mode 10644\n",
       "--- /dev/null\t(" + old_tag + ")\n",
-      "+++ b/" + path_as_shown + "\t(" + new_tag + ")\n",
+      "+++ b/" + path_as_shown + dst_label + "\t(" + new_tag + ")\n",
     ]
   elif delete:
     return [
@@ -79,7 +90,7 @@ def make_git_diff_header(path, old_tag, 
       "===================================================================\n",
       "diff --git a/" + path_as_shown + " b/" + path_as_shown + "\n",
       "deleted file mode 10644\n",
-      "--- a/" + path_as_shown + "\t(" + old_tag + ")\n",
+      "--- a/" + path_as_shown + src_label + "\t(" + old_tag + ")\n",
       "+++ /dev/null\t(" + new_tag + ")\n",
     ]
   elif cp:
@@ -103,8 +114,8 @@ def make_git_diff_header(path, old_tag, 
       "Index: " + path_as_shown + "\n",
       "===================================================================\n",
       "diff --git a/" + path_as_shown + " b/" + path_as_shown + "\n",
-      "--- a/" + path_as_shown + "\t(" + old_tag + ")\n",
-      "+++ b/" + path_as_shown + "\t(" + new_tag + ")\n",
+      "--- a/" + path_as_shown + src_label + "\t(" + old_tag + ")\n",
+      "+++ b/" + path_as_shown + dst_label + "\t(" + new_tag + ")\n",
     ]
 
 
@@ -3147,8 +3158,8 @@ def diff_preexisting_rev_against_local_a
   verify_expected_output(diff_output, "+Re-created file beta.")
 
 # Passes with SVN_EXPERIMENTAL_PATCH defined
-def diff_git_format(sbox):
-  "create a diff in git unidiff format"
+def diff_git_format_wc_wc(sbox):
+  "create a diff in git unidiff format for wc-wc"
   sbox.build()
   wc_dir = sbox.wc_dir
   iota_path = os.path.join(wc_dir, 'iota')
@@ -3161,31 +3172,65 @@ def diff_git_format(sbox):
 
   ### We're not testing copied or moved paths
 
-  exit_code, diff_output, err = svntest.actions.run_and_verify_svn(
-    None, None, [], 'diff', wc_dir)
-  expected_output_lines = make_git_diff_header(mu_path, "revision 1", "working copy", 
-                           delete=True) + [
+  expected_output = make_git_diff_header(mu_path, "revision 1", 
+                                         "working copy", 
+                                         delete=True) + [
     "@@ -1 +0,0 @@\n",
     "-This is the file 'mu'.\n",
+  ] + make_git_diff_header(new_path, "revision 0", "working copy", 
+                           add=True) + [
+    "@@ -0,0 +1 @@\n",
+    "+This is the file 'new'.\n",
   ] +  make_git_diff_header(iota_path, "revision 1", 
                             "working copy") + [
     "@@ -1 +1,2 @@\n",
     " This is the file 'iota'.\n",
     "+Changed 'iota'.\n",
-  ] + make_git_diff_header(new_path, "revision 0", "working copy", 
-                           add=True) + [
+  ]
+
+  svntest.actions.run_and_verify_svn(None, expected_output, [], 'diff', 
+                                     wc_dir)
+
+# Passes with SVN_EXPERIMENTAL_PATCH defined
+def diff_git_format_url_wc(sbox):
+  "create a diff in git unidiff format for url-wc"
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  repo_url = sbox.repo_url
+  iota_path = os.path.join(wc_dir, 'iota')
+  mu_path = os.path.join(wc_dir, 'A', 'mu')
+  new_path = os.path.join(wc_dir, 'new')
+  svntest.main.file_append(iota_path, "Changed 'iota'.\n")
+  svntest.main.file_append(new_path, "This is the file 'new'.\n")
+  svntest.main.run_svn(None, 'add', new_path)
+  svntest.main.run_svn(None, 'rm', mu_path)
+
+  ### We're not testing copied or moved paths
+
+  svntest.main.run_svn(None, 'commit', '-m', 'Committing changes', wc_dir)
+  svntest.main.run_svn(None, 'up', wc_dir)
+
+  expected_output = make_git_diff_header(new_path, "revision 0", "revision 2", 
+                                         dst_label=wc_dir, add=True) + [
     "@@ -0,0 +1 @@\n",
     "+This is the file 'new'.\n",
-  ] 
-
-  # Makes diff output look the same on all platforms.
-  def strip_eols(lines):
-    return [x.replace("\r", "").replace("\n", "") for x in lines]
+  ] + make_git_diff_header(mu_path, "revision 1", 
+                           "working copy", 
+                           src_label=repo_url,
+                           delete=True) + [
+    "@@ -1 +0,0 @@\n",
+    "-This is the file 'mu'.\n",
+  ] +  make_git_diff_header(iota_path, "revision 1", 
+                            "working copy", src_label=repo_url,
+                            dst_label=wc_dir) + [
+    "@@ -1 +1,2 @@\n",
+    " This is the file 'iota'.\n",
+    "+Changed 'iota'.\n",
+  ]
 
-  ### It would be nice to know what lines are not matching in case of a
-  ### failure.
-  if strip_eols(diff_output) != strip_eols(expected_output_lines):
-    raise svntest.Failure
+  svntest.actions.run_and_verify_svn(None, expected_output, [], 'diff', 
+                                     '--old', repo_url + '@1', '--new',
+                                     wc_dir)
 
 ########################################################################
 #Run the tests
@@ -3243,7 +3288,8 @@ test_list = [ None,
               diff_external_diffcmd,
               XFail(diff_url_against_local_mods),
               XFail(diff_preexisting_rev_against_local_add),
-              XFail(diff_git_format),
+              XFail(diff_git_format_wc_wc),
+              XFail(diff_git_format_url_wc),
               ]
 
 if __name__ == '__main__':



Mime
View raw message