Return-Path: Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: (qmail 75709 invoked from network); 2 Mar 2010 21:54:42 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Mar 2010 21:54:42 -0000 Received: (qmail 72064 invoked by uid 500); 2 Mar 2010 21:54:37 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 72036 invoked by uid 500); 2 Mar 2010 21:54:37 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org, commits@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 72029 invoked by uid 99); 2 Mar 2010 21:54:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Mar 2010 21:54:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Mar 2010 21:54:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DDE9A23889DE; Tue, 2 Mar 2010 21:54:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r918211 - /subversion/trunk/subversion/tests/cmdline/svnlook_tests.py Date: Tue, 02 Mar 2010 21:54:13 -0000 To: commits@subversion.apache.org From: lgo@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100302215413.DDE9A23889DE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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__':