Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing YAML from and to a RichEnv should end in the original value [✘] #18

Closed
juhp opened this issue May 14, 2024 · 2 comments · Fixed by #20
Closed

parsing YAML from and to a RichEnv should end in the original value [✘] #18

juhp opened this issue May 14, 2024 · 2 comments · Fixed by #20

Comments

@juhp
Copy link

juhp commented May 14, 2024

For Stackage Nightly:

       Test suite failure for package richenv-0.1.0.1                                                                  [1396/960463]           richenv-test:  exited with: ExitFailure 1                                                                                       Full log available at /home/curators/work/unpack-dir/.stack-work/logs/richenv-0.1.0.1-test.log                                                                                                                                                                                                                                                                                                                                                                                                                                           
           RichEnv                                                                                                                  
             RichEnv ops                                                                                                                           setting environment                                                                                                  
                 set a single environment variable through RichEnv [✔]                                                              
                 set multiple environment variables through RichEnv [✔]                                                             
                 remaps existing environment variables [✔]                                                                          
                 remaps prefixed variables [✔]                                                                                      
               getting the environment variable list                                                                                
                 gets the environment variable list [✔]                                                                             
                 gets the environment variable list with prefixes [✔]                                                               
               working with YAML                                                                                                                     parses a YAML file into expected results [✔]                                                                       
               working with JSON                                                                                                    
                 parses a JSON file into expected results [✔]                                                                       
               invariants                                                                                                           
                 parsing YAML from and to a RichEnv should end in the original value [✘]                                            
                 parsing JSON from and to a RichEnv should end in the original value [✔]
                   +++ OK, passed 100 tests.
           RichEnv.Setters
             mappings
               returns an empty environment when given an empty set [✔]
               remaps a single environment variable [✔]
             prefixes
               returns an empty environment when given an empty set [✔]
               remaps a single environment variable [✔]
               passes all environment variables adding a prefix [✔]
               remaps prefixed environment variables removing the prefix [✔]
               passes only prefixed environment variables preserving the prefix [✔]
               passes all environment variables [✔]
               passes multiple prefixes to multiple new prefixes [✔]
               passes multiple prefixes to a single new prefix [✔]
            
           Failures:
            
             test/RichEnvSpec.hs:98:22: 
             1) RichEnv, RichEnv ops, invariants, parsing YAML from and to a RichEnv should end in the original value
                 Falsifiable (after 43 tests):
                    RichEnv {values = Values {unValues = fromList [("\CAN\1107954\DC1L{","\"T\SO-*9$o)\ETX1\aG7HV\DEL\3877\&5\RS`\18
9190\EOTV\147307\r\1009054"),("\155690q\66888\18657\v85\DEL\995997\FS+.U1:7\SO\149161G\140585\b)\US\ETB\1030596_l14-\b\NAK\SUBNJL\DL
E\1082774<","P\DC4\150679EJ\vy\97104\DC3\SIR\140971Jf\21792~"),("WJ\EOT\SIJ,!\182685E\175121V+7\20810\EOT\bWRvM\38572\989336\173201\
143222$X\1036167Mp\121423\23112\159477y\1074072&jb\1031174\199757\172064\n","$\\"),("\1066993\a;\92561KA\ESC\30638","1\177514\118806
\a~\NAK\1034496\179825\1089969\175437\"Mer\SOH\194946b\SOH[Z(u"),("X4\ETB6`I9gm&G\GS>2ZI\45244 \145589S_{?\DC1nEW{\NUL\"@\v\ACK-r\EN
Q","SJs\EMWZ\NAK\52475\&9\151003\ENQA\"S\SI2\"&\38555:V\1095230HQsv~gOU@Q\1050978\&4"),("@$6\NULv\26760{{Qsf\1015937\DLE)\1002274\"\
1032412\DC36}M\STXvP^FD'x/x","\1079203>E\ETX\1062868w\EOT\RS\CAN_pu\a\157398\GS\v\n\STXMap]:\132094'"),("|T","\1010066<\DC4[F\54498\
&3\ETB\205548\&5\a\DC1\13588_28\1063494\&1&J5\SOH\188135V\NAK")]}, mappings = Mappings {unMappings = fromList [("\7567QFeZ\42384\971
23nE`0q",")*Z\200846:\1053162RT\1087669"),("\SOH\EM\175493\SIR\1097866\&7Y\58528\185463O\SOH\142715son\148767C\1084113\1053194\&8\b"
,"i\\\1064962\&8\15428gp\ENQ=J\n\DC4J\92354r\1047389\FS\46591Y#\1037042M^w7de8\NULL;\ENQ6t\163525"),("\NAK\53562\1058674KP-\1050637\
1019303fn8BF\152935\ESC\SO\RS\ENQ$`{\DC2\STXB\989994`k\1045333","A\1069573"),("L\47326","\13548P\NUL~H\EMe+/\27151\8180I\100683\&3>}
:
:
:
           
             To rerun use: --match "/RichEnv/RichEnv ops/invariants/parsing YAML from and to a RichEnv should end in the original value/" --seed 1128272235
           
           Randomized with seed 1128272235
           
           Finished in 1.4684 seconds
           20 examples, 1 failure

@DavSanchez
Copy link
Owner

Hi! Thanks for reporting. I'll reproduce and work on a fix.

@DavSanchez
Copy link
Owner

Turns out the YAML bytestring generation done by the yaml library does not quote some of the map keys. The offending case was a mapping with a << key that then was not parsed correctly back into a RichEnv value. Just switching the dependency to use HsYAML and HsYAML-aeson seems to fix the test. I'll do this change and test more extensively to close this.

In any case I'm being too liberal with the generation of environment variable names for tests, allowing just arbitrary values of Text. I should probably align with the POSIX standard for shells and assume uppercase letters, digits, and the '_' (underscore) not beginning with a digit.

I don't think I'll break any use case by restricting to this, but I'll add that on a different version. This could allow me to switch back to the yaml dependency if needed.

@DavSanchez DavSanchez linked a pull request May 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants