Author: kotkov
Date: Wed Nov 23 12:30:51 2022
New Revision: 1905482

URL: http://svn.apache.org/viewvc?rev=1905482&view=rev
Log:
On the 'pristines-on-demand-on-mwf' branch: Rework the conditional checks
in the Python test suite.

Now the pristine mode is a property of the working copy [settings], rather
than format.  So let's use `svn info --show-item=store-pristine` to access
that state where it is necessary.

* subversion/tests/cmdline/svntest/sandbox.py
  (Sandbox.pristines_on_demand_enabled): Remove.

* subversion/tests/cmdline/svntest/actions.py
  (get_wc_store_pristine): New helper.  Use it …

* subversion/tests/cmdline/authz_tests.py
  (cat_base_after_repo_access_removed): …here, …

* subversion/tests/cmdline/move_tests.py
  (move_conflict_details): …here, …

* subversion/tests/cmdline/trans_tests.py
  (keywords_from_birth, eol_change_is_text_mod): …here, …

* subversion/tests/cmdline/update_tests.py
  (another_hudson_problem): …and here.

* subversion/tests/cmdline/upgrade_tests.py
  (check_pristine): Use the new helper to skip white-box check of the
   file contents at wc.text_base_path().

Modified:
    
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/authz_tests.py
    
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/move_tests.py
    
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/actions.py
    
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/sandbox.py
    
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/trans_tests.py
    
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/update_tests.py
    
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/upgrade_tests.py

Modified: 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/authz_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/authz_tests.py?rev=1905482&r1=1905481&r2=1905482&view=diff
==============================================================================
--- 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/authz_tests.py
 (original)
+++ 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/authz_tests.py
 Wed Nov 23 12:30:51 2022
@@ -1835,11 +1835,11 @@ def cat_base_after_repo_access_removed(s
 
   # With repository read access denied, expect we can still access the
   # text base locally, if and only if text bases are present.
-  if sbox.pristines_on_demand_enabled():
-    svntest.actions.run_and_verify_svn(None, '.*E170001: Authorization failed',
+  if svntest.actions.get_wc_store_pristine(wc_dir):
+    svntest.actions.run_and_verify_svn("This is the file 'pi'.\n", [],
                                        'cat', sbox.ospath('A/D/G/pi') + 
'@BASE')
   else:
-    svntest.actions.run_and_verify_svn("This is the file 'pi'.\n", [],
+    svntest.actions.run_and_verify_svn(None, '.*E170001: Authorization failed',
                                        'cat', sbox.ospath('A/D/G/pi') + 
'@BASE')
 
 

Modified: 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/move_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/move_tests.py?rev=1905482&r1=1905481&r2=1905482&view=diff
==============================================================================
--- 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/move_tests.py
 (original)
+++ 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/move_tests.py
 Wed Nov 23 12:30:51 2022
@@ -1599,10 +1599,10 @@ def move_conflict_details(sbox):
   sbox.simple_append('B/E/new-dir3', 'something')
   sbox.simple_add('B/E/new-dir3')
 
+  store_pristine = svntest.actions.get_wc_store_pristine(sbox.wc_dir)
 
   expected_output = svntest.verify.RegexListOutput(
-    (["Fetching text bases [.]+done"]
-      if sbox.pristines_on_demand_enabled() else [])
+    ([] if store_pristine else ["Fetching text bases [.]+done"])
     +
     [re.escape(x) for x in [
       " C   %s\n" % sbox.ospath('B'),         # Property conflicted

Modified: 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/actions.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/actions.py?rev=1905482&r1=1905481&r2=1905482&view=diff
==============================================================================
--- 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/actions.py
 (original)
+++ 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/actions.py
 Wed Nov 23 12:30:51 2022
@@ -2089,6 +2089,20 @@ def get_wc_base_rev(wc_dir):
   "Return the BASE revision of the working copy at WC_DIR."
   return run_and_parse_info(wc_dir)[0]['Revision']
 
+def get_wc_store_pristine(wc_dir):
+  "Return whether the working copy at WC_DIR stores pristine contents."
+  _, output, _ = run_and_verify_svn(
+    None, [],
+    'info', '--show-item=store-pristine', '--no-newline',
+    wc_dir)
+
+  if output == ['yes']:
+    return True
+  elif output == ['no']:
+    return False
+  else:
+    raise verify.SVNUnexpectedStdout(output)
+
 def load_dumpfile(filename):
   "Return the contents of the FILENAME assuming that it is a dump file"
   with open(filename, "rb") as fp:

Modified: 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/sandbox.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/sandbox.py?rev=1905482&r1=1905481&r2=1905482&view=diff
==============================================================================
--- 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/sandbox.py
 (original)
+++ 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/svntest/sandbox.py
 Wed Nov 23 12:30:51 2022
@@ -629,9 +629,6 @@ class Sandbox:
           ret[root[len(self.wc_dir)+1:]] = self._wc_format_of(wc_db_path)
     return { k.replace(os.sep, '/') : ret[k] for k in ret }
 
-  def pristines_on_demand_enabled(self, relpath=''):
-    return self.read_wc_formats().get(relpath, 0) == 32
-
 def is_url(target):
   return (target.startswith('^/')
           or target.startswith('file://')

Modified: 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/trans_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/trans_tests.py?rev=1905482&r1=1905481&r2=1905482&view=diff
==============================================================================
--- 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/trans_tests.py
 (original)
+++ 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/trans_tests.py
 Wed Nov 23 12:30:51 2022
@@ -395,14 +395,14 @@ def keywords_from_birth(sbox):
 
   # Read the text base. In pristines-on-demand mode it isn't stored locally
   # after commit, so read it from the repo.
-  if sbox.pristines_on_demand_enabled():
-    _, actual_textbase_kw, _ = svntest.main.run_svn(False,
-                                 'cat', '-rHEAD', '--ignore-keywords',
-                                 fixed_length_keywords_path)
-  else:
+  if svntest.actions.get_wc_store_pristine(wc_dir):
     fp = open(svntest.wc.text_base_path(fixed_length_keywords_path), 'r')
     actual_textbase_kw = fp.readlines()
     fp.close()
+  else:
+    _, actual_textbase_kw, _ = svntest.main.run_svn(False,
+                                 'cat', '-rHEAD', '--ignore-keywords',
+                                 fixed_length_keywords_path)
 
   check_keywords(actual_textbase_kw, kw_textbase, "text base")
 
@@ -605,7 +605,7 @@ def eol_change_is_text_mod(sbox):
     if contents != b"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n":
       raise svntest.Failure
 
-  if not sbox.pristines_on_demand_enabled():
+  if svntest.actions.get_wc_store_pristine(wc_dir):
     foo_base_path = svntest.wc.text_base_path(foo_path)
     base_contents = open(foo_base_path, 'rb').read()
     if contents != base_contents:

Modified: 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/update_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/update_tests.py?rev=1905482&r1=1905481&r2=1905482&view=diff
==============================================================================
--- 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/update_tests.py
 (original)
+++ 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/update_tests.py
 Wed Nov 23 12:30:51 2022
@@ -1189,7 +1189,7 @@ def another_hudson_problem(sbox):
                      'Updated to revision 3.\n',
                     ]
   expected_output = [re.escape(s) for s in expected_output]
-  if sbox.pristines_on_demand_enabled():
+  if not svntest.actions.get_wc_store_pristine(wc_dir):
     expected_output.append('Fetching text bases [.]*done\n')
 
   # Sigh, I can't get run_and_verify_update to work (but not because

Modified: 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/upgrade_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/upgrade_tests.py?rev=1905482&r1=1905481&r2=1905482&view=diff
==============================================================================
--- 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/upgrade_tests.py
 (original)
+++ 
subversion/branches/pristines-on-demand-on-mwf/subversion/tests/cmdline/upgrade_tests.py
 Wed Nov 23 12:30:51 2022
@@ -119,16 +119,11 @@ def check_formats(sbox, expected_formats
 def check_pristine(sbox, files):
   for file in files:
     file_path = sbox.ospath(file)
-    file_text = open(file_path, 'r').read()
-    try:
+    if svntest.actions.get_wc_store_pristine(file_path):
+      file_text = open(file_path, 'r').read()
       file_pristine = open(svntest.wc.text_base_path(file_path), 'r').read()
-    except (FileNotFoundError, svntest.Failure): # FileNotFoundError
-      if sbox.pristines_on_demand_enabled(''):
-        # Pristine missing; pristines optional so ignore it
-        continue
-      raise
-    if (file_text != file_pristine):
-      raise svntest.Failure("pristine mismatch for '%s'" % (file))
+      if (file_text != file_pristine):
+        raise svntest.Failure("pristine mismatch for '%s'" % (file))
 
 def check_dav_cache(dir_path, wc_id, expected_dav_caches):
   dot_svn = svntest.main.get_admin_name()


Reply via email to