On Thu, Oct 17, 2019 at 5:48 PM Daniel Shahaf <d...@daniel.shahaf.name>
wrote:

> Good morning Nathan,
>

Good morning! Or whatever time it happens to be in your part of the world
:-)

If instead of using «echo test > file» you would use the existing file
> 'iota'
> (see subversion/tests/README), you'd be able to pass read_only=True to
> sbox.build(), which avoids some test suite overhead in setting a dedicated
> repository for each test function — i.e., makes tests run half a
> millisecond faster. ☺


Thank you for this suggestion!

So I tried this:

[[[

#----------------------------------------------------------------------
# Regression test for issue #1722: 'svn diff' produced a wrong header,
# indicating one revision as being in the working copy when it should
# be 'nonexistent'
@Issue(1722)
def diff_nonexistent_in_wc(sbox):
  "nonexistent in working copy"

  sbox.build(read_only=True)
  wc_dir = sbox.wc_dir

  sbox.simple_update(revision=0)

  # Expected output is empty for these cases:
  # svn diff -r BASE
  # svn diff -r 0:BASE
  # svn diff -r 0

  # Expected output for:
  # svn diff -r BASE:HEAD
  # svn diff -r 0:HEAD
  # svn diff -r 0:1
  expected_output_base_head = make_diff_header("iota", "nonexistent",
                                               "revision 1") + [
  "@@ -0,0 +1 @@\n",
  "+This is the file 'iota'.\n",
  ]

  # Expected output for:
  # svn diff -r HEAD:BASE
  # svn diff -r HEAD
  # svn diff -r 1:0
  # svn diff -r 1
  expected_output_head_base = make_diff_header("iota", "revision 1",
                                               "nonexistent") + [
  "@@ -1 +0,0 @@\n",
  "-This is the file 'iota'.\n"
  ]

  os.chdir(wc_dir)

  svntest.actions.run_and_verify_svn(expected_output_base_head, [],
                                     'diff', '-r', 'BASE:HEAD')

  svntest.actions.run_and_verify_svn(expected_output_head_base, [],
                                     'diff', '-r', 'HEAD:BASE')

  svntest.actions.run_and_verify_svn([], [],
                                     'diff', '-r', 'BASE')

  svntest.actions.run_and_verify_svn(expected_output_head_base, [],
                                     'diff', '-r', 'HEAD')

  svntest.actions.run_and_verify_svn([], [],
                                     'diff', '-r', '0:BASE')

  svntest.actions.run_and_verify_svn(expected_output_base_head, [],
                                     'diff', '-r', '0:HEAD')

  svntest.actions.run_and_verify_svn(expected_output_base_head, [],
                                     'diff', '-r', '0:1')

  svntest.actions.run_and_verify_svn(expected_output_head_base, [],
                                     'diff', '-r', '1:0')

  svntest.actions.run_and_verify_svn([], [],
                                     'diff', '-r', '0')

  svntest.actions.run_and_verify_svn(expected_output_head_base, [],
                                     'diff', '-r', '1')

]]]

I like shorter code!

Unfortunately, instead of reproducing the output shown in SVN-1722,
it now produces a much longer diff that includes all the files, some
60+ lines, and consequently fails the test, but that could be fixed,
but...

While I could run 'svn diff -r BASE:HEAD iota' etc., I think that
would be the wrong thing to do because SVN-1722 is so old that we
don't know exactly what circumstances used to trigger it. What if
we change the test to save some milliseconds and end up defeating
the purpose? I don't know. Do you think it's worth it?

Nathan

Reply via email to