Patch 2328 tests fix: don't generate random date strings for Patc...

Title tests fix: don't generate random date strings for Patc...
Superseder Nosy List ganesh
Related Issues
Status accepted Assigned To

Created on 2023-07-10.09:59:01 by ganesh, last changed 2023-07-16.17:23:00 by ganesh.

File name Status Uploaded Type Edit Remove
patch-preview.txt ganesh, 2023-07-10.09:58:43 text/x-darcs-patch
tests-fix_-don_t-generate-random-date-strings-for-patchinfo.dpatch ganesh, 2023-07-10.09:58:44 application/x-darcs-patch
See mailing list archives for discussion on individual patches.
msg23518 (view) Author: ganesh Date: 2023-07-10.09:58:44
A long explanation for a short fix :-)

I'm surprised this hasn't gone wrong before as I saw it as
soon as I wrote a (new) failing test - I guess our web of
generators means it isn't always used in the same way.

Old patch references:


1 patch for repository darcs-unstable@darcs.net:/opt/darcs/screened:

patch ee42ad9d53fa8cbd938657c8a51b4fa2846bda73
Author: Ganesh Sittampalam <ganesh@earth.li>
Date:   Mon Jul 10 08:44:18 BST 2023
  * tests fix: don't generate random date strings for PatchInfo

  Although we check that they contain a limited range of
  characters that are valid in dates, we don't check that they
  actually parse as dates. As Darcs.Patch.Info.friendlyD parses
  these strings even when just printing out a patch in order to
  shift timezones, this makes these values unusable.

  This follows on from this patch which added the initial

  > patch 403698ffdc7b41b9840ccad632915f82a848b644
  > Author: Ben Franksen <ben.franksen@online.de>
  > Date:   Mon Mar 12 22:42:53 CET 2018
  >  * add validation for PatchInfo items, add unit test for parse/unparse

  and this patch which applied a similar fix in another place:

  > patch ba25e53c0bbbe23ab84f07447af346aa5059ecd8
  > Author: Ben Franksen <ben.franksen@online.de>
  > Date:   Fri Nov 16 21:26:05 CET 2018
  >  * fix: insert a valid date when creating anonymous named patch

  In future we could revamp this more so that we can

  (a) generate actual arbitrary dates - though this is unlikely to
      be actually important for tests

  (b) replace validDate with logic that fully parses the date
msg23522 (view) Author: bfrk Date: 2023-07-10.12:58:40
Thanks for this one! Some time ago I generalized the patch tests to include 
quickcheck tests for Named patches, too. These regularly failed with error calls 
because we generated invalid date strings. I hope this will now be fixed and I 
can send and screen them.
msg23530 (view) Author: bfrk Date: 2023-07-10.14:26:04
Now that we no longer generate (potentially) invalid dates, 
shrinking gives me an "invalid patch name" error (for Named 

    resolutions are invariant under reorderings: [Failed]
*** Failed! (after 486 tests and 8 shrinks):
Exception while generating shrink-list:
  invalid patch name 

Do you have a simple fix for that, too?
msg23533 (view) Author: ganesh Date: 2023-07-10.19:35:25
> Now that we no longer generate (potentially) invalid dates, 
> shrinking gives me an "invalid patch name" error (for Named 
> RepoPatchV3):

> Do you have a simple fix for that, too?

Afraid not, I didn't run into it myself. I had a very quick glance
and I'm not even sure why it happens as shrinkPatchInfo calls
shrink on a ByteString and I don't know what code that ends up
msg23592 (view) Author: ganesh Date: 2023-07-16.15:27:35
Self-accepting as it's a test fix that's a definite improvement even if
it doesn't solve all our test generation problems.
Date User Action Args
2023-07-10 09:59:01ganeshcreate
2023-07-10 10:01:08ganeshsetstatus: needs-screening -> needs-review
2023-07-10 12:58:42bfrksetmessages: + msg23522
2023-07-10 14:26:05bfrksetmessages: + msg23530
2023-07-10 19:35:28ganeshsetmessages: + msg23533
2023-07-16 15:27:35ganeshsetstatus: needs-review -> accepted-pending-tests
messages: + msg23592
2023-07-16 17:23:00ganeshsetstatus: accepted-pending-tests -> accepted