yesodweb / css-text

CSS parser and renderer.
MIT License
16 stars 8 forks source link

css-text 0.1.2.2 test suite failure #11

Open DanBurton opened 8 years ago

DanBurton commented 8 years ago

As seen on the stackage build server:

> /tmp/stackage-build8/css-text-0.1.2.2$ dist/build/runtests/runtests

single attribute parser
  trimming whitespace
multiple attribute parser
  no final semicolon
  final semicolon
  ignores comments
block parser
  multiple blocks
  media queries
render
  works
parse/render
  idempotent blocks
  idempotent nested blocks FAILED [1]

Failures:

  runtests.hs:65:
  1) parse/render idempotent nested blocks
       Falsifiable (after 10 tests and 2 shrinks):
       [NestedBlock "screen" [LeafBlock ("e6TSwOB",[("FL3A","CYm"),("-O398","Kp3ifbY-")]),LeafBlock ("ogr",[("1z9Hh","z64_kkL-"),("Z","VTrmiw"),("X","qY")]),LeafBlock ("lnExDh_t",[("GvGRPQ7","_eLM95y")])],LeafBlock ("DL-HA",[("5j__","TP"),("9JC0WT7Q3","CVmgtau"),("YkBPswb5","E"),("tq","E-wN1JeX"),("OtJ1mp","wj")])]

Randomized with seed 483934590

Finished in 6.7949 seconds
9 examples, 1 failure

I was able to reproduce this test suite failure on my local machine like so:

stack unpack css-text-0.1.2.2
cd css-text-0.1.2.2/
stack init --resolver nightly-2016-07-09
stack test
DanBurton commented 8 years ago

To clarify, this was actually seen in the lts build. I see now that css-text is already in the "skipped-tests" section of build-constraints.yaml.

nomeata commented 7 years ago

We see this in Debian as well, and would love to have a fixed version of css-text to use.

iustin commented 7 years ago

I was lucky to get a minimal test case: [NestedBlock "screen" []]. Sadly the documentation for this library is not clear enough to allow me to understand whether the issue is in render or in parse.

The render of this is screen{} which is however parsed back as [LeafBlock ("screen",[])], not as a nested block. The minimal nested block that is parsed back correctly is [NestedBlock "screen" [LeafBlock ("a",[])]]. Is a nested block with an empty child list an actual valid nested block?

The example given in the first comment is even more interesting. Pretty-printing the actual value makes it more readable:

[ NestedBlock
    "screen"
    [ LeafBlock
        ( "e6TSwOB" , [ ( "FL3A" , "CYm" ) , ( "-O398" , "Kp3ifbY-" ) ] )
    , LeafBlock
        ( "ogr"
        , [ ( "1z9Hh" , "z64_kkL-" )
          , ( "Z" , "VTrmiw" )
          , ( "X" , "qY" )
          ]
        )
    , LeafBlock ( "lnExDh_t" , [ ( "GvGRPQ7" , "_eLM95y" ) ] )
    ]
, LeafBlock
    ( "DL-HA"
    , [ ( "5j__" , "TP" )
      , ( "9JC0WT7Q3" , "CVmgtau" )
      , ( "YkBPswb5" , "E" )
      , ( "tq" , "E-wN1JeX" )
      , ( "OtJ1mp" , "wj" )
      ]
    )
]

and this parses back to an empty list of blocks. Rendering and parsing back just the first element of the list (the NestedBlock one) looks correct, and the same for rendering+parsing the LeafBlock. But parsing the two together is completely broken…