You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2018/11/06 08:16:05 UTC

svn commit: r1845874 - /subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py

Author: brane
Date: Tue Nov  6 08:16:05 2018
New Revision: 1845874

URL: http://svn.apache.org/viewvc?rev=1845874&view=rev
Log:
Add a bunch of peg-revision parsing tests.

The failing tests are marked work-in-progress instead of XFAIL, so that
the descriptions of the failures are visible in the test output instead
of being limited to an obscure comment in the test program.

* subversion/tests/cmdline/pegrev_parse_tests.py
  (run_svn, do_add_file, do_make_dir): New helper functions.
  (do_rename): Renamed and modified from do_move_with_at_signs.

  (move_file_subdir_2_dst_escape_peg):
   Renamed from move_to_target_with_leading_and_trailing_at_sign.
  (move_file_subdir_2_no_dst_escape_peg):
   Renamed from move_to_target_with_leading_at_sign.

  (add_file_here_*, add_file_subdir_*,
   make_dir_here_*, make_dir_subdir_*): 46 new test cases.

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

Modified: subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py?rev=1845874&r1=1845873&r2=1845874&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py Tue Nov  6 08:16:05 2018
@@ -33,6 +33,7 @@ logger = logging.getLogger()
 import svntest
 from svntest import wc
 from svntest import main
+from svntest import actions
 
 # (abbreviation)
 Skip = svntest.testcase.Skip_deco
@@ -46,36 +47,318 @@ Item = wc.StateItem
 ######################################################################
 # Helper functions
 
-def do_move_with_at_signs(sbox, src, dst, dst_cmdline):
+# Most of our tests use absolute paths as parameters on the command line. But
+# for these tests, it's important that we can use bare file names in the
+# commands, because the parser may have (and as of this writing does have)
+# edge-case bugs that we can only expose in this way. Therefore, these helpers
+# ensure that we run 'svn' with the CWD at the root of the working copy.
+def run_svn(sbox, expected_status, expected_stderr, *varargs):
+  if expected_stderr is None:
+    expected_stderr = []
+
+  cwd = os.getcwd()
+  try:
+    os.chdir(sbox.wc_dir)
+    actions.run_and_verify_svn(None, expected_stderr, *varargs)
+  finally:
+    os.chdir(cwd)
+
+  if expected_status is not None:
+    actions.run_and_verify_status(sbox.wc_dir, expected_status)
+
+def get_trojan_virginal_state(sbox, rev=1):
+  return actions.get_virginal_state(sbox.wc_dir, rev, tree='trojan')
+
+def do_add_file(sbox, dst, dst_cmdline, expected_stderr=None):
+  sbox.build(tree='trojan')
+  main.file_write(sbox.ospath(dst), "This is file '"  + dst + "'.")
+
+  if expected_stderr is None:
+    expected_status = get_trojan_virginal_state(sbox)
+    expected_status.add({dst: Item(status='A ', wc_rev='-')})
+  else:
+    expected_status = None
+
+  run_svn(sbox, expected_status, expected_stderr,
+          'add', dst_cmdline)
+
+def do_make_dir(sbox, dst, dst_cmdline, expected_stderr=None):
+  sbox.build(tree='trojan')
+
+  if expected_stderr is None:
+    expected_status = get_trojan_virginal_state(sbox)
+    expected_status.add({dst: Item(status='A ', wc_rev='-')})
+  else:
+    expected_status = None
+
+  run_svn(sbox, expected_status, expected_stderr,
+          'mkdir', dst_cmdline)
+
+def do_rename(sbox, src, src_cmdline, dst, dst_cmdline, expected_stderr=None):
   sbox.build(tree='trojan')
 
-  expected_status = main.trojan_state.copy()
-  expected_status.tweak(src, status='D ', moved_to=dst)
-  expected_status.add({dst: Item(status='A ', copied='+',
-                                 moved_from=src, wc_rev='-')})
+  if expected_stderr is None:
+    expected_status = get_trojan_virginal_state(sbox)
+    expected_status.tweak(src, status='D ', moved_to=dst)
+    expected_status.add({dst: Item(status='A ', copied='+',
+                                   moved_from=src, wc_rev='-')})
+  else:
+    expected_status = None
+
+  run_svn(sbox, expected_status, expected_stderr,
+          'rename', src_cmdline, dst_cmdline)
 
-  sbox.simple_move(src, dst_cmdline)
-  svntest.actions.run_and_verify_status(sbox.wc_dir, expected_status)
 
 ######################################################################
 # Tests
 #
 #   Each test must return on success or raise on failure.
 
-@XFail()
-@Issue(4530)
-def move_to_target_with_leading_at_sign(sbox):
-  "rename to dir/@file"
+#=====================================================================
+# Tests for 'svn add' in the current directory
+
+def add_file_here_1_escape_peg(sbox):
+  "add file 'tau' with pegrev escape"
+  do_add_file(sbox, 'tau', 'tau@')
+
+def add_file_here_2_escape_peg(sbox):
+  "add file '@tau' with pegrev escape"
+  do_add_file(sbox, '@tau', '@tau@')
+
+def add_file_here_3_escape_peg(sbox):
+  "add file '_@tau' with pegrev escape"
+  do_add_file(sbox, '_@tau', '_@tau@')
+
+def add_file_here_4_escape_peg(sbox):
+  "add file '.@tau' with pegrev escape"
+  do_add_file(sbox, '.@tau', '.@tau@')
+
+def add_file_here_5_escape_peg(sbox):
+  "add file 'tau@' with pegrev escape"
+  do_add_file(sbox, 'tau@', 'tau@@')
+
+def add_file_here_6_escape_peg(sbox):
+  "add file '@tau@' with pegrev escape"
+  do_add_file(sbox, '@tau@', '@tau@@')
+
+#---------------------------------------------------------------------
+
+def add_file_here_1_no_escape_peg(sbox):
+  "add file 'tau' without pegrev escape"
+  do_add_file(sbox, 'tau', 'tau')
+
+def add_file_here_2_no_escape_peg(sbox):
+  "add file '@tau' without pegrev escape"
+  do_add_file(sbox, '@tau', '@tau', "svn: E125001: '@tau'")
+
+def add_file_here_3_no_escape_peg(sbox):
+  "add file '_@tau' without pegrev escape"
+  do_add_file(sbox, '_@tau', '_@tau', "svn: E200009: '_@tau'")
+
+@Wimp("The error message mentions '@tau' instead of '.@tau'")
+def add_file_here_4_no_escape_peg(sbox):
+  "add file '.@tau' without pegrev escape"
+  do_add_file(sbox, '.@tau', '.@tau', "svn: E200009: '.@tau'")
+
+def add_file_here_5_no_escape_peg(sbox):
+  "add file 'tau@' without pegrev escape"
+  do_add_file(sbox, 'tau@', 'tau@', 'svn: E200009: ')
+
+def add_file_here_6_no_escape_peg(sbox):
+  "add file '@tau@' without pegrev escape"
+  do_add_file(sbox, '@tau@', '@tau@', 'svn: E200009: ')
+
+#=====================================================================
+# Tests for 'svn add' in a subdirectory
+
+def add_file_subdir_1_escape_peg(sbox):
+  "add file 'E/tau' with pegrev escape"
+  do_add_file(sbox, 'E/tau', 'E/tau@')
+
+def add_file_subdir_2_escape_peg(sbox):
+  "add file 'E/@tau' with pegrev escape"
+  do_add_file(sbox, 'E/@tau', 'E/@tau@')
+
+def add_file_subdir_3_escape_peg(sbox):
+  "add file 'E/_@tau' with pegrev escape"
+  do_add_file(sbox, 'E/_@tau', 'E/_@tau@')
+
+def add_file_subdir_4_escape_peg(sbox):
+  "add file 'E/.@tau' with pegrev escape"
+  do_add_file(sbox, 'E/.@tau', 'E/.@tau@')
+
+def add_file_subdir_5_escape_peg(sbox):
+  "add file 'E/tau@' with pegrev escape"
+  do_add_file(sbox, 'E/tau@', 'E/tau@@')
+
+def add_file_subdir_6_escape_peg(sbox):
+  "add file 'E/@tau@' with pegrev escape"
+  do_add_file(sbox, 'E/@tau@', 'E/@tau@@')
+
+#---------------------------------------------------------------------
+
+def add_file_subdir_1_no_escape_peg(sbox):
+  "add file 'E/tau' without pegrev escape"
+  do_add_file(sbox, 'E/tau', 'E/tau')
+
+@Wimp("The error message mentions 'E@tau' instead of 'E/@tau'")
+@Wimp("The error message should be E125001")
+def add_file_subdir_2_no_escape_peg(sbox):
+  "add file 'E/@tau' without pegrev escape"
+  do_add_file(sbox, 'E/@tau', 'E/@tau', "svn: E200009: 'E/@tau'")
 
-  do_move_with_at_signs(sbox, 'iota', 'A/@upsilon', 'A/@upsilon')
+def add_file_subdir_3_no_escape_peg(sbox):
+  "add file 'E/_@tau' without pegrev escape"
+  do_add_file(sbox, 'E/_@tau', 'E/_@tau', "svn: E200009: 'E/_@tau'")
 
+@Wimp("The error message mentions 'E@tau' instead of 'E/.@tau'")
+def add_file_subdir_4_no_escape_peg(sbox):
+  "add file 'E/.@tau' without pegrev escape"
+  do_add_file(sbox, 'E/.@tau', 'E/.@tau', "svn: E200009: 'E/.@tau'")
 
-@XFail()
+def add_file_subdir_5_no_escape_peg(sbox):
+  "add file 'E/tau@' without pegrev escape"
+  do_add_file(sbox, 'E/tau@', 'E/tau@', 'svn: E200009: ')
+
+def add_file_subdir_6_no_escape_peg(sbox):
+  "add file 'E/@tau@' without pegrev escape"
+  do_add_file(sbox, 'E/@tau@', 'E/@tau@', 'svn: E200009: ')
+
+
+#=====================================================================
+# Tests for 'svn mkdir' in the current directory
+
+def make_dir_here_1_escape_peg(sbox):
+  "create directory 'T' with pegrev escape"
+  do_make_dir(sbox, 'T', 'T@')
+
+def make_dir_here_2_escape_peg(sbox):
+  "create directory '@T' with pegrev escape"
+  do_make_dir(sbox, '@T', '@T@')
+
+def make_dir_here_3_escape_peg(sbox):
+  "create directory '_@T' with pegrev escape"
+  do_make_dir(sbox, '_@T', '_@T@')
+
+def make_dir_here_4_escape_peg(sbox):
+  "create directory '.@T' with pegrev escape"
+  do_make_dir(sbox, '.@T', '.@T@')
+
+def make_dir_here_5_escape_peg(sbox):
+  "create directory 'T@' with pegrev escape"
+  do_make_dir(sbox, 'T@', 'T@@')
+
+def make_dir_here_6_escape_peg(sbox):
+  "create directory '@T@' with pegrev escape"
+  do_make_dir(sbox, '@T@', '@T@@')
+
+#---------------------------------------------------------------------
+
+def make_dir_here_1_no_escape_peg(sbox):
+  "create directory 'T' without pegrev escape"
+  do_make_dir(sbox, 'T', 'T')
+
+def make_dir_here_2_no_escape_peg(sbox):
+  "create directory '@T' without pegrev escape"
+  do_make_dir(sbox, '@T', '@T', "svn: E125001: '@T'")
+
+def make_dir_here_3_no_escape_peg(sbox):
+  "create directory '_@T' without pegrev escape"
+  do_make_dir(sbox, '_@T', '_@T', "svn: E200009: '_@T'")
+
+@Wimp("The error message mentions '@T' instead of '.@T'")
+def make_dir_here_4_no_escape_peg(sbox):
+  "create directory '.@T' without pegrev escape"
+  do_make_dir(sbox, '.@T', '.@T', "svn: E200009: '.@T'")
+
+# Skip tests 5 and 6 that create a directory with a trailing @ in the name
+# because is correctly interpreted as a peg revision escape. This is already
+# tested by:
+#   - make_dir_here_5_escape_peg
+#   - make_dir_here_6_escape_peg
+
+#=====================================================================
+# Tests for 'svn add' in a subdirectory
+
+def make_dir_subdir_1_escape_peg(sbox):
+  "create directory 'E/T' with pegrev escape"
+  do_make_dir(sbox, 'E/T', 'E/T@')
+
+def make_dir_subdir_2_escape_peg(sbox):
+  "create directory 'E/@T' with pegrev escape"
+  do_make_dir(sbox, 'E/@T', 'E/@T@')
+
+def make_dir_subdir_3_escape_peg(sbox):
+  "create directory 'E/_@T' with pegrev escape"
+  do_make_dir(sbox, 'E/_@T', 'E/_@T@')
+
+def make_dir_subdir_4_escape_peg(sbox):
+  "create directory 'E/.@T' with pegrev escape"
+  do_make_dir(sbox, 'E/.@T', 'E/.@T@')
+
+def make_dir_subdir_5_escape_peg(sbox):
+  "create directory 'E/T@' with pegrev escape"
+  do_make_dir(sbox, 'E/T@', 'E/T@@')
+
+def make_dir_subdir_6_escape_peg(sbox):
+  "create directory 'E/@T@' with pegrev escape"
+  do_make_dir(sbox, 'E/@T@', 'E/@T@@')
+
+def make_dir_subdir_7_escape_peg(sbox):
+  "create directory 'E/@' with pegrev escape"
+  do_make_dir(sbox, 'E/@', 'E/@@')
+
+#---------------------------------------------------------------------
+
+def make_dir_subdir_1_no_escape_peg(sbox):
+  "create directory 'E/T' without pegrev escape"
+  do_make_dir(sbox, 'E/T', 'E/T')
+
+@Wimp("The error message mentions 'E@T' instead of 'E/@T'")
+@Wimp("The error message should be E125001")
+def make_dir_subdir_2_no_escape_peg(sbox):
+  "create directory 'E/@T' without pegrev escape"
+  do_make_dir(sbox, 'E/@T', 'E/@T', "svn: E200009: 'E/@T'")
+
+def make_dir_subdir_3_no_escape_peg(sbox):
+  "create directory 'E/_@T' without pegrev escape"
+  do_make_dir(sbox, 'E/_@T', 'E/_@T', "svn: E200009: 'E/_@T'")
+
+@Wimp("The error message mentions 'E@T' instead of 'E/.@T'")
+def make_dir_subdir_4_no_escape_peg(sbox):
+  "create directory 'E/.@T' without pegrev escape"
+  do_make_dir(sbox, 'E/.@T', 'E/.@T', "svn: E200009: 'E/.@T'")
+
+# Skip tests 5 and 6 that create a directory with a trailing @ in the name
+# because is correctly interpreted as a peg revision escape. This is already
+# tested by:
+#   - make_dir_subdir_5_escape_peg
+#   - make_dir_subdir_6_escape_peg
+
+def make_dir_subdir_7_no_escape_peg(sbox):
+  "create directory 'E/@' without pegrev escape"
+  do_make_dir(sbox, 'E/@', 'E/@', 'svn: E000017: ')
+
+#=====================================================================
+# Test for 'svn move' to a subdirectory
+
+@Wimp("Rename creates 'E/@tau@' instead of '@/@tau'")
 @Issue(4530)
-def move_to_target_with_leading_and_trailing_at_sign(sbox):
-  "rename to dir/@file@"
+def move_file_subdir_2_dst_escape_peg(sbox):
+  "rename 'iota' to 'E/@tau with pegrev escape"
+  # NOTE: This rename succeeds, but creates E/@tau@ instead of E/@tau, even
+  #       though it should strip away the pegrev escape from the target.
+  do_rename(sbox, 'iota', 'iota', 'E/@tau', 'E/@tau@')
+
+#---------------------------------------------------------------------
 
-  do_move_with_at_signs(sbox, 'iota', 'A/@upsilon', 'A/@upsilon@')
+@Wimp("Rename creates 'E@tau' instead of failing")
+@Issue(4530)
+def move_file_subdir_2_no_dst_escape_peg(sbox):
+  "rename 'iota' to 'E/@tau without pegrev escape"
+  # NOTE: This rename succeeds, but creates E@tau in the current directory,
+  #       when instead it should fail with 'svn: E125001: ...'.
+  do_rename(sbox, 'iota', 'iota', 'E/@tau', 'E/@tau') ### 'svn: E200009: '
 
 
 ########################################################################
@@ -83,8 +366,66 @@ def move_to_target_with_leading_and_trai
 
 # list all tests here, starting with None:
 test_list = [ None,
-              move_to_target_with_leading_at_sign,
-              move_to_target_with_leading_and_trailing_at_sign,
+              add_file_here_1_escape_peg,
+              add_file_here_2_escape_peg,
+              add_file_here_3_escape_peg,
+              add_file_here_4_escape_peg,
+              add_file_here_5_escape_peg,
+              add_file_here_6_escape_peg,
+
+              add_file_here_1_no_escape_peg,
+              add_file_here_2_no_escape_peg,
+              add_file_here_3_no_escape_peg,
+              add_file_here_4_no_escape_peg,
+              add_file_here_5_no_escape_peg,
+              add_file_here_6_no_escape_peg,
+
+              add_file_subdir_1_escape_peg,
+              add_file_subdir_2_escape_peg,
+              add_file_subdir_3_escape_peg,
+              add_file_subdir_4_escape_peg,
+              add_file_subdir_5_escape_peg,
+              add_file_subdir_6_escape_peg,
+
+              add_file_subdir_1_no_escape_peg,
+              add_file_subdir_2_no_escape_peg,
+              add_file_subdir_3_no_escape_peg,
+              add_file_subdir_4_no_escape_peg,
+              add_file_subdir_5_no_escape_peg,
+              add_file_subdir_6_no_escape_peg,
+
+              make_dir_here_1_escape_peg,
+              make_dir_here_2_escape_peg,
+              make_dir_here_3_escape_peg,
+              make_dir_here_4_escape_peg,
+              make_dir_here_5_escape_peg,
+              make_dir_here_6_escape_peg,
+
+              make_dir_here_1_no_escape_peg,
+              make_dir_here_2_no_escape_peg,
+              make_dir_here_3_no_escape_peg,
+              make_dir_here_4_no_escape_peg,
+              # skipped: make_dir_here_5_no_escape_peg
+              # skipped: make_dir_here_6_no_escape_peg
+
+              make_dir_subdir_1_escape_peg,
+              make_dir_subdir_2_escape_peg,
+              make_dir_subdir_3_escape_peg,
+              make_dir_subdir_4_escape_peg,
+              make_dir_subdir_5_escape_peg,
+              make_dir_subdir_6_escape_peg,
+              make_dir_subdir_7_escape_peg,
+
+              make_dir_subdir_1_no_escape_peg,
+              make_dir_subdir_2_no_escape_peg,
+              make_dir_subdir_3_no_escape_peg,
+              make_dir_subdir_4_no_escape_peg,
+              # skipped: make_dir_subdir_5_no_escape_peg
+              # skipped: make_dir_subdir_6_no_escape_peg
+              make_dir_subdir_7_no_escape_peg,
+
+              move_file_subdir_2_dst_escape_peg,
+              move_file_subdir_2_no_dst_escape_peg,
              ]
 
 if __name__ == '__main__':



Re: svn commit: r1845874 - /subversion/trunk/subversion/tests/cmdline/pegrev_parse_tests.py

Posted by Branko Čibej <br...@apache.org>.
On 06.11.2018 09:16, brane@apache.org wrote:
> Author: brane
> Date: Tue Nov  6 08:16:05 2018
> New Revision: 1845874
>
> URL: http://svn.apache.org/viewvc?rev=1845874&view=rev
> Log:
> Add a bunch of peg-revision parsing tests.

[...]

> +def make_dir_subdir_7_no_escape_peg(sbox):
> +  "create directory 'E/@' without pegrev escape"
> +  do_make_dir(sbox, 'E/@', 'E/@', 'svn: E000017: ')

Note to self: this expected stderr is probably wrong ... it's EEXIST on
macOS (because the trailing @ is stripped away from the target) but the
actual number will very likely not be the same on all platforms.

-- Brane