adamgundry / uom-plugin

Units of measure as a GHC typechecker plugin
30 stars 5 forks source link

Doctest, cannot set package flags with :seti; use :set #89

Open philderbeast opened 3 years ago

philderbeast commented 3 years ago

I'm building with stack against ghc-9.0.1 and noticed this error called out for stack test uom-plugin-tutorial:doctest but not for cabal test uom-plugin-tutorial:doctest --project-file=901.cabal.project regarding the following line:

https://github.com/adamgundry/uom-plugin/blob/f92df5464e7d496082fba841af3263a070050e80/uom-plugin/doc/Data/UnitsOfMeasure/Tutorial.hs#L80

> stack test uom-plugin-tutorial:doctest
uom-plugin-tutorial> test (suite: doctest)

./doc/Data/UnitsOfMeasure/Tutorial.hs:80: failure in expression
`:seti -fplugin Data.UnitsOfMeasure.Plugin -XDataKinds -XQuasiQuotes -XTypeOperators'
expected:
 but got: cannot set package flags with :seti; use :set
          ^

./doc/Data/UnitsOfMeasure/Tutorial.hs:151: failure in expression
`:seti -XPartialTypeSignatures -fno-warn-partial-type-signatures'
expected:
 but got: cannot set package flags with :seti; use :set
          ^

Examples: 64  Tried: 54  Errors: 0  Failures: 2

uom-plugin-tutorial> Test suite doctest failed
Test suite failure for package uom-plugin-tutorial-0.3.0.1
    doctest:  exited with: ExitFailure 1
> cabal test uom-plugin:doctest --project-file=901.cabal.project
Build profile: -w ghc-9.0.1 -O0
In order, the following will be built (use -v for more details):
 - uom-plugin-0.4.0.0 (test:doctest) (ephemeral targets)
Preprocessing test suite 'doctest' for uom-plugin-0.4.0.0..
Building test suite 'doctest' for uom-plugin-0.4.0.0..
Running 1 test suites...
Test suite doctest: RUNNING...
Test suite doctest: PASS
Test suite logged to:
/.../ghc-9.0.1/uom-plugin-0.4.0.0/t/doctest/noopt/test/uom-plugin-0.4.0.0-doctest.log
1 of 1 test suites (1 of 1 test cases) passed.

From the ghc-9.2 branch, this change to stack.yaml reproduces the problem:

-    resolver: lts-11.22
+    resolver: nightly-2021-08-08
     packages:
     - build
     - uom-plugin
     - uom-plugin-tutorial
     - uom-plugin-examples
     extra-deps:
-    - units-parser-0.1.0.0
+    - units-parser-0.1.1.4
philderbeast commented 3 years ago

I made a mistake in the initial report:

- > cabal test uom-plugin:doctest --project-file=901.cabal.project
+ > cabal test uom-plugin-tutorial:doctest --project-file=901.cabal.project

With that change, cabal fails too but for a different reason:

> cabal test uom-plugin-tutorial:doctest --project-file=901.cabal.project
Build profile: -w ghc-9.0.1 -O0
In order, the following will be built (use -v for more details):
 - uom-plugin-tutorial-0.3.0.1 (test:doctest) (ephemeral targets)
Preprocessing test suite 'doctest' for uom-plugin-tutorial-0.3.0.1..
Building test suite 'doctest' for uom-plugin-tutorial-0.3.0.1..
Running 1 test suites...
Test suite doctest: RUNNING...

doc/Data/UnitsOfMeasure/Tutorial.hs:50:1: error:
    Could not load module ‘Data.UnitsOfMeasure’
    It is a member of the hidden package ‘uom-plugin-0.4.0.0’.
    You can run ‘:set -package uom-plugin’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
50 | import Data.UnitsOfMeasure
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

Test suite doctest: FAIL
Test suite logged to:
/.../ghc-9.0.1/uom-plugin-tutorial-0.3.0.1/t/doctest/noopt/test/uom-plugin-tutorial-0.3.0.1-doctest.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal: Tests failed for test:doctest from uom-plugin-tutorial-0.3.0.1.
philderbeast commented 3 years ago

@adamgundry I got this to compile for the stack build with https://github.com/adamgundry/uom-plugin/pull/90 by changing seti to set. As this is for the tutorial and in GHCI seti is the way to go, perhaps we could use set for the doctest while showing seti in the haddocks?

I think we could do this using an unreferenced chunk?

philderbeast commented 3 years ago

With regard the cabal test failure, adding -package uom-plugin to the doctest setup worked but I stashed that change, blew away the dist-newstyle folder and tried again and found the failure with cabal test to be not reproducible.