You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by lg...@apache.org on 2010/03/02 22:54:13 UTC

svn commit: r918211 - /subversion/trunk/subversion/tests/cmdline/svnlook_tests.py

Author: lgo
Date: Tue Mar  2 21:54:13 2010
New Revision: 918211

URL: http://svn.apache.org/viewvc?rev=918211&view=rev
Log:
Add test for 'svnlook [cmd] -t'.

* subversion/tests/svnlook.py
  (verify_logfile): Helper function.
  (test_txn_flag): New test.
  (test_list): Run the new test, should pass.

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

Modified: subversion/trunk/subversion/tests/cmdline/svnlook_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnlook_tests.py?rev=918211&r1=918210&r2=918211&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnlook_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnlook_tests.py Tue Mar  2 21:54:13 2010
@@ -577,6 +577,96 @@
                             "'svnlook cat's output differ for the path "
                             "'%s'." % (line))
 
+#----------------------------------------------------------------------
+def verify_logfile(logfilename, expected_data):
+  if os.path.exists(logfilename):
+    fp = open(logfilename)
+  else:
+    raise svntest.verify.SVNUnexpectedOutput("hook logfile %s not found"\
+                                             % logfilename)
+
+  actual_data = fp.readlines()
+  fp.close()
+  os.unlink(logfilename)
+  svntest.verify.compare_and_display_lines('wrong hook logfile content',
+                                           'STDOUT',
+                                           expected_data, actual_data)
+
+def test_txn_flag(sbox):
+  "test 'svnlook * -t'"
+
+  sbox.build()
+  repo_dir = sbox.repo_dir
+  wc_dir = sbox.wc_dir
+  logfilepath = os.path.join(repo_dir, 'hooks.log')
+
+  # List changed dirs and files in this transaction
+  hook_template = """import sys,os,subprocess
+svnlook_bin=%s
+
+fp = open(os.path.join(sys.argv[1], 'hooks.log'), 'wb')
+def output_command(fp, cmd, opt):
+  command = [svnlook_bin, cmd, '-t', sys.argv[2], sys.argv[1]] + opt
+  process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
+  (output, errors) = process.communicate()
+  status = process.returncode
+  fp.write(output)
+  fp.write(errors)
+  return status
+
+for (svnlook_cmd, svnlook_opt) in %s:
+  output_command(fp, svnlook_cmd, svnlook_opt.split(' '))
+fp.close()"""
+  pre_commit_hook = svntest.main.get_pre_commit_hook_path(repo_dir)
+
+  # 1. svnlook 'changed' -t and 'dirs-changed' -t
+  hook_instance = hook_template % (repr(svntest.main.svnlook_binary),
+                                   repr([('changed', ''),
+                                         ('dirs-changed', '')]))
+  svntest.main.create_python_hook_script(pre_commit_hook,
+                                         hook_instance)
+
+  # Change files mu and rho
+  A_path = os.path.join(wc_dir, 'A')
+  mu_path = os.path.join(wc_dir, 'A', 'mu')
+  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
+  svntest.main.file_append(mu_path, 'appended mu text')
+  svntest.main.file_append(rho_path, 'new appended text for rho')
+
+  # commit, and check the hook's logfile
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'ci', '-m', 'log msg', wc_dir)
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'up', wc_dir)
+
+  expected_data = [ 'U   A/D/G/rho\n', 'U   A/mu\n', 'A/\n', 'A/D/G/\n' ]
+  verify_logfile(logfilepath, expected_data)
+
+  # 2. svnlook 'propget' -t, 'proplist' -t
+  # 2. Change a dir and revision property
+  hook_instance = hook_template % (repr(svntest.main.svnlook_binary),
+                                   repr([('propget', 'bogus_prop /A'),
+                                         ('propget', '--revprop bogus_rev_prop'),
+                                         ('proplist', '/A'),
+                                         ('proplist', '--revprop')]))
+  svntest.main.create_python_hook_script(pre_commit_hook,
+                                         hook_instance)
+
+  svntest.actions.run_and_verify_svn(None, None, [], 'propset',
+                                     'bogus_prop', 'bogus_val\n', A_path)
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'ci', '-m', 'log msg', wc_dir,
+                                     '--with-revprop', 'bogus_rev_prop=bogus_rev_val\n')
+  # Now check the logfile
+  expected_data = [ 'bogus_val\n',
+                    'bogus_rev_val\n',
+                    '  bogus_prop\n',
+                    '  svn:log\n', '  svn:author\n',
+                    #  internal property, not really expected
+                    '  svn:check-locks\n',
+                    '  bogus_rev_prop\n', '  svn:date\n']
+  verify_logfile(logfilepath, expected_data)
+
 ########################################################################
 # Run the tests
 
@@ -596,6 +686,7 @@
               diff_ignore_eolstyle,
               diff_binary,
               test_filesize,
+              test_txn_flag,
              ]
 
 if __name__ == '__main__':