Skip to content

Failing test with whitespace mismatches for hls-splice-plugin #1808

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

Closed
maralorn opened this issue May 7, 2021 · 11 comments
Closed

Failing test with whitespace mismatches for hls-splice-plugin #1808

maralorn opened this issue May 7, 2021 · 11 comments
Assignees
Labels
component: hls-splice-plugin old_type: distribution type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@maralorn
Copy link
Contributor

maralorn commented May 7, 2021

Your environment

Trying to build hls-splice-plugin-1.0.0.1.

Which OS do you use: Nixos

Steps to reproduce

I ran the tests.

Expected behaviour

Tests pass.

Actual behaviour

  TSimpleDecl.hs (golden):      FAIL (111.47s)
    test/Main.hs:87:
    expected: "{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE QuasiQuotes #-}\r\nmodule TSimpleDecl where\r\nimport Language.Haskell.TH ( mkName, clause, normalB, funD, sigD )\r\n\r\n-- Foo\r\n--  Bar\r\nfoo :: Int\r\nfoo = 42\r\n-- Bar\r\n-- ee\r\n-- dddd\r\n"
     but got: "{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE QuasiQuotes #-}\r\nmodule TSimpleDecl where\r\nimport Language.Haskell.TH ( mkName, clause, normalB, funD, sigD )\r\n\r\n-- Foo\r\n--  Bar\r\nfoo :: Int\nfoo = 42\r\n-- Bar\r\n-- ee\r\n-- dddd\r\n"
  TQQDecl.hs (golden):          FAIL (133.83s)
    test/Main.hs:87:
    expected: "{-# LANGUAGE QuasiQuotes #-}\r\nmodule TQQDecl where\r\nimport QQ (str)\r\n\r\nfoo :: String\r\nfoo = \"foo\"\r\n"
     but got: "{-# LANGUAGE QuasiQuotes #-}\r\nmodule TQQDecl where\r\nimport QQ (str)\r\n\r\nfoo :: String\nfoo = \"foo\"\r\n"
  TTypeKindError.hs (golden):   OK (125.31s)
  TDeclKindError.hs (golden):   FAIL (118.40s)
    test/Main.hs:120:
    expected: "{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE QuasiQuotes #-}\r\nmodule TSimpleDecl where\r\nimport Language.Haskell.TH ( mkName, clause, normalB, funD, sigD )\r\n\r\n-- Foo\r\n--  Bar\r\nfoo :: Int\r\nfoo = 42\r\nbar :: Int\r\n-- Bar\r\n-- ee\r\n-- dddd\r\n"
     but got: "{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE QuasiQuotes #-}\r\nmodule TSimpleDecl where\r\nimport Language.Haskell.TH ( mkName, clause, normalB, funD, sigD )\r\n\r\n-- Foo\r\n--  Bar\r\nfoo :: Int\nfoo = 42\nbar :: Int\r\n-- Bar\r\n-- ee\r\n-- dddd\r\n"

3 out of 31 tests failed (138.46s)

This looks like some issue with unix vs. windows line endings?

@jneira jneira added component: hls-splice-plugin os: nixos type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. type: testing labels May 8, 2021
@felixonmars
Copy link
Contributor

I am getting the same errors when building for Arch:

  TSimpleDecl.hs (golden):      FAIL (88.82s)
    test/Main.hs:87:
    expected: "{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE QuasiQuotes #-}\r\nmodule TSimpleDecl where\r\nimport Language.Haskell.TH ( mkName, clause, normalB, funD, sigD )\r\n\r\n-- Foo\r\n--  Bar\r\nfoo :: Int\r\nfoo = 42\r\n-- Bar\r\n-- ee\r\n-- dddd\r\n"
     but got: "{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE QuasiQuotes #-}\r\nmodule TSimpleDecl where\r\nimport Language.Haskell.TH ( mkName, clause, normalB, funD, sigD )\r\n\r\n-- Foo\r\n--  Bar\r\nfoo :: Int\nfoo = 42\r\n-- Bar\r\n-- ee\r\n-- dddd\r\n"
  TQQDecl.hs (golden):          FAIL (102.13s)
    test/Main.hs:87:
    expected: "{-# LANGUAGE QuasiQuotes #-}\r\nmodule TQQDecl where\r\nimport QQ (str)\r\n\r\nfoo :: String\r\nfoo = \"foo\"\r\n"
     but got: "{-# LANGUAGE QuasiQuotes #-}\r\nmodule TQQDecl where\r\nimport QQ (str)\r\n\r\nfoo :: String\nfoo = \"foo\"\r\n"
  TTypeKindError.hs (golden):   OK (99.71s)
  TDeclKindError.hs (golden):   FAIL (93.87s)
    test/Main.hs:120:
    expected: "{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE QuasiQuotes #-}\r\nmodule TSimpleDecl where\r\nimport Language.Haskell.TH ( mkName, clause, normalB, funD, sigD )\r\n\r\n-- Foo\r\n--  Bar\r\nfoo :: Int\r\nfoo = 42\r\nbar :: Int\r\n-- Bar\r\n-- ee\r\n-- dddd\r\n"
     but got: "{-# LANGUAGE TemplateHaskell #-}\r\n{-# LANGUAGE QuasiQuotes #-}\r\nmodule TSimpleDecl where\r\nimport Language.Haskell.TH ( mkName, clause, normalB, funD, sigD )\r\n\r\n-- Foo\r\n--  Bar\r\nfoo :: Int\nfoo = 42\nbar :: Int\r\n-- Bar\r\n-- ee\r\n-- dddd\r\n"

@jneira
Copy link
Member

jneira commented May 11, 2021

Usually tests fail in windows cause the same issue 🙂 , editing the source test cases should fix it, i suppose

@Ailrun
Copy link
Member

Ailrun commented May 11, 2021

It's partially because splice plugin does not use any golden test util, and implement its own pseudo-golden test by itself... (If we use git diff, we can ignore \r differences)

@berberman
Copy link
Collaborator

berberman commented May 11, 2021

Yeah, eval plugin and tactics plugin have the same problem as well.

And it turns out that files in uploaded tarballs are different from those in our git source tree:

$ diff ~/Downloads/hls-splice-plugin-1.0.0.1/test/testdata/TErrorExp.hs.expected ~/haskell-language-server/plugins/hls-splice-plugin/test/testdata/TErrorExp.hs.expected   
1,6c1,6
< {-# LANGUAGE TemplateHaskell #-}
< module TErrorExp where
< import Language.Haskell.TH ( tupE, litE, integerL )
< 
< main :: IO ()
< main = return (42, ())
---
> {-# LANGUAGE TemplateHaskell #-}
> module TErrorExp where
> import Language.Haskell.TH ( tupE, litE, integerL )
> 
> main :: IO ()
> main = return (42, ())

@jneira Did you create this sdist on Windows?

@jneira
Copy link
Member

jneira commented May 11, 2021

yeah, it seems it could be my fault, maybe cause i have auto.crlf enabled (not at my laptop rigt now).
I will take a look asap

@jneira jneira self-assigned this May 11, 2021
@maralorn
Copy link
Contributor Author

It's partially because splice plugin does not use any golden test util, and implement its own pseudo-golden test by itself... (If we use git diff, we can ignore \r differences)

btw. git diff also leads to problems on nixos because it shows differences in file permissions caused by the nix-store. But it’s okay. We can of course disable them …

@Ailrun
Copy link
Member

Ailrun commented May 11, 2021

@maralorn That issue is now fixed on master (and probably after next version)

@jneira
Copy link
Member

jneira commented May 12, 2021

I've checked mye env and:

PS D:\hls> git config --get auto.crlf
false

and i have the .editorconfig plugin installed so it should change crlf by lf on save (although i did not open those test data files iirc)

🤔

EDIT: never mind, i've set the config option wrong (it is core.autocrlf) 🤦

@jneira
Copy link
Member

jneira commented May 12, 2021

Ok i forced a checkout after fixing the damn core.autocrlf and all files have LF now. So i will bump up the plugin to 1.0.0.2 in master, backport the change to hackage-1.1.0 and upload the tarball again
Sorry for the inconveniences caused by that stupid error 😟

@jneira
Copy link
Member

jneira commented May 13, 2021

I've uploaded https://hackage.haskell.org/package/hls-splice-plugin-1.0.0.2 after double checking files have LF.

Akthough i am gonna use unix LF cause i want to be kind with my fellow posix comrades 😝 , tests should be resilient to line endings changes, like other plugins, as suggested by @Ailrun

@maralorn tests should work now (at least they shouldn't fail due to line endings)

@jneira jneira added the status: needs info Not actionable, because there's missing information label May 13, 2021
@felixonmars
Copy link
Contributor

I've uploaded https://hackage.haskell.org/package/hls-splice-plugin-1.0.0.2 after double checking files have LF.

Akthough i am gonna use unix LF cause i want to be kind with my fellow posix comrades stuck_out_tongue_closed_eyes , tests should be resilient to line endings changes, like other plugins, as suggested by @Ailrun

@maralorn tests should work now (at least they shouldn't fail due to line endings)

Confirmed that the tests are passing now in Arch. Thanks!

archlinux/svntogit-community@ffc8dbe#diff-37538beb61ff63edebbf735dfcf39e5d732f49183d6beb097169d971875ca422L42

@jneira jneira removed the status: needs info Not actionable, because there's missing information label May 16, 2021
@jneira jneira closed this as completed May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-splice-plugin old_type: distribution type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

5 participants