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

Document how to add internal libraries to test-suite dependencies when cabal-version is 3.4 or higher (add example to cabal file format docs) #8069

Closed
infrmtcs opened this issue Mar 28, 2022 · 4 comments · Fixed by #8642

Comments

@infrmtcs
Copy link

Describe the bug
We need to add internal libraries as test suite dependencies. However, the build fail if cabal-version in *.cabal file is updated to 3.4 or 3.6.

To Reproduce
#6961 regression test fails when modifying cabal-version:
infrmtcs@9a7478b

$ cabal v2-run exe:cabal-tests -- --with-cabal $(which cabal) cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.test.hs

Expected behavior
Being able to add internal dependencies to test suites when cabal-version is 3.4 or higher.

System information

  • MacOS Big Sur 11.6
  • cabal 3.6.2.0 + ghc 9.2.2 and cabal 3.6.0.0 + ghc 8.10.7

Additional context
N/A

@infrmtcs
Copy link
Author

Log:

$ cabal v2-run exe:cabal-tests -- --with-cabal $(which cabal) cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.test.hs
Up to date
/Users/infrmtcs/.ghcup/ghc/9.2.2/bin/runghc-9.2.2 -- '--ghc-arg=-i' '--ghc-arg=-no-user-package-db' '--ghc-arg=-package-db' '--ghc-arg=/Users/infrmtcs/.cabal/store/ghc-9.2.2/package.db' '--ghc-arg=-package-db' '--ghc-arg=/Users/infrmtcs/haskell/cabal/dist-newstyle/packagedb/ghc-9.2.2' '--ghc-arg=-package-id' '--ghc-arg=Cabal-3.7.0.0-inplace' '--ghc-arg=-package-id' '--ghc-arg=Cabal-syntax-3.7.0.0-inplace' '--ghc-arg=-package-id' '--ghc-arg=sync-2.2.4-cfb217a2' '--ghc-arg=-package-id' '--ghc-arg=base-4.16.1.0' '--ghc-arg=-package-id' '--ghc-arg=cabal-testsuite-3-inplace' '--ghc-arg=-package-id' '--ghc-arg=clck-0.8.3-b6748794' '--ghc-arg=-package-id' '--ghc-arg=exceptions-0.10.4' '--ghc-arg=-package-id' '--ghc-arg=filepath-1.4.2.2' '--ghc-arg=-package-id' '--ghc-arg=ptprs-pplctv-0.16.1.0-fec7c138' '--ghc-arg=-package-id' '--ghc-arg=prcss-1.6.14.0-e25bc31e' '--ghc-arg=-package-id' '--ghc-arg=transformers-0.5.6.2' cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.test.hs --builddir /Users/infrmtcs/haskell/cabal/dist-newstyle/build/x86_64-osx/ghc-9.2.2/cabal-testsuite-3 cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.test.hs --with-cabal /Users/infrmtcs/.ghcup/bin/cabal
# cabal v2-build
+ /Users/infrmtcs/.ghcup/bin/cabal v2-build '-vverbose +markoutput +nowrap' --builddir /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work/./dist --project-file cabal.project -j1 all --dry-run --enable-tests
Project settings changed, reconfiguring...
creating /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work/dist
creating /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work
creating /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work/dist
creating /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work/dist/cache
this build was affected by the following (project) config files:
- /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.project
Compiler settings changed, reconfiguring...
/Users/infrmtcs/.ghcup/bin/ghc --numeric-version
looking for tool ghc-pkg near compiler in /Users/infrmtcs/.ghcup/bin
found ghc-pkg in /Users/infrmtcs/.ghcup/ghc/9.2.2/bin/ghc-pkg-9.2.2
/Users/infrmtcs/.ghcup/ghc/9.2.2/bin/ghc-pkg-9.2.2 --version
/Users/infrmtcs/.ghcup/bin/ghc --supported-languages
/Users/infrmtcs/.ghcup/bin/ghc --info
/Users/infrmtcs/.ghcup/bin/ghc --print-global-package-db
Warning: No remote package servers have been specified. Usually you would have one specified in the config file.
/usr/local/bin/pkg-config --version
/usr/local/bin/pkg-config --variable pc_path pkg-config
/usr/local/bin/pkg-config --version
/usr/local/bin/pkg-config --list-all
/usr/local/bin/pkg-config --modversion libtasn1 gio-unix-2.0 libjxl libzmq libecpg_compat gobject-introspection-no-export-1.0 libpostproc applewmproto gio-2.0 zlib cairo-xcb xf86dgaproto ncursesw xcb-composite cairo-gobject harfbuzz-icu hogweed libpng16 cairo-quartz-font opus gnutls-dane cairo-ps xcb-xevie libswscale gmodule-2.0 p11-kit-1 glib-2.0 rubberband xdmcp x264 x265 libvmaf xau expat dmxproto randrproto xcb-damage aom gmpxx opencore-amrnb vidstab libpcre2-16 lept xcb-xvmc libavdevice libevent_core xcb-ge resourceproto libedit presentproto fontsproto samplerate glproto uuid libpcrecpp libhwy libavutil libevent_pthreads sdl2 libexslt gmodule-no-export-2.0 libavformat theoradec xrender libidn2 bigreqsproto OpenEXR rav1e liblzma dav1d xext xcb-record bdw-gc pthread-stubs xcb-xtest libzstd xcb libass gobject-introspection-1.0 opencore-amrwb libiodbc xcb-randr xproto renderproto lcms2 xcb-present isl guile-3.0 yaml-0.1 libavfilter libbrotlidec libpcre2-32 soxr-lsr apr-util-1 libevent libxml-2.0 libavcodec flac libevent_openssl xcb-sync cairo-pdf videoproto vpx libb2 librist sndfile xcb-xv xcb-shm x11-xcb xcb-xprint xcb-shape libwebpmux graphite2 libwebpdecoder 'flac++' apr-1 zimg vorbisfile xcb-xkb libbrotlicommon gmodule-export-2.0 dri3proto libjpeg x11 libpq cairo-xlib ncurses tesseract libffi fixesproto kbproto xcb-xinput gnutls nettle libcjson cairo-xcb-shm xcb-dri3 pixman-1 xcb-dri2 cairo-quartz-image xcb-xselinux libbluray compositeproto haisrt libpcre2-8 damageproto xf86driproto inputproto libpcre16 sqlite3 srt libtiff-4 cmocka vorbisenc dri2proto gobject-2.0 gthread-2.0 python-3.9 cairo-fc libnghttp2 libunbound liblz4 harfbuzz-subset xcb-dpms python3 libopenjp2 mpfr libpcreposix python-3.9-embed libjxl_threads libwebp cairo dpmsproto libhwy-test cairo-png cairo-xlib-xrender cairo-ft libpng xcb-res xf86vidmodeproto fontconfig libecpg xextproto theora libpcre2-posix xcmiscproto soxr ogg python3-embed theoraenc xf86bigfontproto cairo-svg libsodium cairo-quartz libcurl xineramaproto scrnsaverproto vorbis recordproto harfbuzz libcjson_utils speex xcb-render lzo2 libpgtypes frei0r libpcre cairo-script libpcre32 xcb-xinerama libbrotlienc cairo-tee freetype2 Imath xcb-xf86dri fribidi libhwy-contrib libevent_extra xcb-xfixes xcb-screensaver libswresample gmp oniguruma harfbuzz-gobject libwebpdemux xcb-glx libxslt
-----BEGIN CABAL OUTPUT-----
Resolving dependencies...
-----END CABAL OUTPUT-----

-----BEGIN CABAL OUTPUT-----
cabal: Could not resolve dependencies:
[__0] trying: issue6961-0 (user goal)
[__1] rejecting: issue6961:!test (constraint from config file, command line flag, or user target requires opposite flag selection)
[__1] trying: issue6961:*test
[__2] unknown package: internal-lib (dependency of issue6961 *test)
[__2] fail (backjumping, conflict set: internal-lib, issue6961, issue6961:test)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: issue6961 (3), issue6961:test (3), internal-lib (1)
-----END CABAL OUTPUT-----

cabal.test.hs: Command /Users/infrmtcs/.ghcup/bin/cabal v2-build '-vverbose +markoutput +nowrap' --builddir /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work/./dist --project-file cabal.project -j1 all --dry-run --enable-tests failed.
Output:
Project settings changed, reconfiguring...
creating /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work/dist
creating /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work
creating /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work/dist
creating /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.dist/work/dist/cache
this build was affected by the following (project) config files:
- /Users/infrmtcs/haskell/cabal/cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.project
Compiler settings changed, reconfiguring...
/Users/infrmtcs/.ghcup/bin/ghc --numeric-version
looking for tool ghc-pkg near compiler in /Users/infrmtcs/.ghcup/bin
found ghc-pkg in /Users/infrmtcs/.ghcup/ghc/9.2.2/bin/ghc-pkg-9.2.2
/Users/infrmtcs/.ghcup/ghc/9.2.2/bin/ghc-pkg-9.2.2 --version
/Users/infrmtcs/.ghcup/bin/ghc --supported-languages
/Users/infrmtcs/.ghcup/bin/ghc --info
/Users/infrmtcs/.ghcup/bin/ghc --print-global-package-db
Warning: No remote package servers have been specified. Usually you would have one specified in the config file.
/usr/local/bin/pkg-config --version
/usr/local/bin/pkg-config --variable pc_path pkg-config
/usr/local/bin/pkg-config --version
/usr/local/bin/pkg-config --list-all
/usr/local/bin/pkg-config --modversion libtasn1 gio-unix-2.0 libjxl libzmq libecpg_compat gobject-introspection-no-export-1.0 libpostproc applewmproto gio-2.0 zlib cairo-xcb xf86dgaproto ncursesw xcb-composite cairo-gobject harfbuzz-icu hogweed libpng16 cairo-quartz-font opus gnutls-dane cairo-ps xcb-xevie libswscale gmodule-2.0 p11-kit-1 glib-2.0 rubberband xdmcp x264 x265 libvmaf xau expat dmxproto randrproto xcb-damage aom gmpxx opencore-amrnb vidstab libpcre2-16 lept xcb-xvmc libavdevice libevent_core xcb-ge resourceproto libedit presentproto fontsproto samplerate glproto uuid libpcrecpp libhwy libavutil libevent_pthreads sdl2 libexslt gmodule-no-export-2.0 libavformat theoradec xrender libidn2 bigreqsproto OpenEXR rav1e liblzma dav1d xext xcb-record bdw-gc pthread-stubs xcb-xtest libzstd xcb libass gobject-introspection-1.0 opencore-amrwb libiodbc xcb-randr xproto renderproto lcms2 xcb-present isl guile-3.0 yaml-0.1 libavfilter libbrotlidec libpcre2-32 soxr-lsr apr-util-1 libevent libxml-2.0 libavcodec flac libevent_openssl xcb-sync cairo-pdf videoproto vpx libb2 librist sndfile xcb-xv xcb-shm x11-xcb xcb-xprint xcb-shape libwebpmux graphite2 libwebpdecoder 'flac++' apr-1 zimg vorbisfile xcb-xkb libbrotlicommon gmodule-export-2.0 dri3proto libjpeg x11 libpq cairo-xlib ncurses tesseract libffi fixesproto kbproto xcb-xinput gnutls nettle libcjson cairo-xcb-shm xcb-dri3 pixman-1 xcb-dri2 cairo-quartz-image xcb-xselinux libbluray compositeproto haisrt libpcre2-8 damageproto xf86driproto inputproto libpcre16 sqlite3 srt libtiff-4 cmocka vorbisenc dri2proto gobject-2.0 gthread-2.0 python-3.9 cairo-fc libnghttp2 libunbound liblz4 harfbuzz-subset xcb-dpms python3 libopenjp2 mpfr libpcreposix python-3.9-embed libjxl_threads libwebp cairo dpmsproto libhwy-test cairo-png cairo-xlib-xrender cairo-ft libpng xcb-res xf86vidmodeproto fontconfig libecpg xextproto theora libpcre2-posix xcmiscproto soxr ogg python3-embed theoraenc xf86bigfontproto cairo-svg libsodium cairo-quartz libcurl xineramaproto scrnsaverproto vorbis recordproto harfbuzz libcjson_utils speex xcb-render lzo2 libpgtypes frei0r libpcre cairo-script libpcre32 xcb-xinerama libbrotlienc cairo-tee freetype2 Imath xcb-xf86dri fribidi libhwy-contrib libevent_extra xcb-xfixes xcb-screensaver libswresample gmp oniguruma harfbuzz-gobject libwebpdemux xcb-glx libxslt
-----BEGIN CABAL OUTPUT-----
Resolving dependencies...
-----END CABAL OUTPUT-----

-----BEGIN CABAL OUTPUT-----
cabal: Could not resolve dependencies:
[__0] trying: issue6961-0 (user goal)
[__1] rejecting: issue6961:!test (constraint from config file, command line flag, or user target requires opposite flag selection)
[__1] trying: issue6961:*test
[__2] unknown package: internal-lib (dependency of issue6961 *test)
[__2] fail (backjumping, conflict set: internal-lib, issue6961, issue6961:test)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: issue6961 (3), issue6961:test (3), internal-lib (1)
-----END CABAL OUTPUT-----



cabal-tests: callProcess: /Users/infrmtcs/.ghcup/ghc/9.2.2/bin/runghc-9.2.2 "--" "--ghc-arg=-i" "--ghc-arg=-no-user-package-db" "--ghc-arg=-package-db" "--ghc-arg=/Users/infrmtcs/.cabal/store/ghc-9.2.2/package.db" "--ghc-arg=-package-db" "--ghc-arg=/Users/infrmtcs/haskell/cabal/dist-newstyle/packagedb/ghc-9.2.2" "--ghc-arg=-package-id" "--ghc-arg=Cabal-3.7.0.0-inplace" "--ghc-arg=-package-id" "--ghc-arg=Cabal-syntax-3.7.0.0-inplace" "--ghc-arg=-package-id" "--ghc-arg=sync-2.2.4-cfb217a2" "--ghc-arg=-package-id" "--ghc-arg=base-4.16.1.0" "--ghc-arg=-package-id" "--ghc-arg=cabal-testsuite-3-inplace" "--ghc-arg=-package-id" "--ghc-arg=clck-0.8.3-b6748794" "--ghc-arg=-package-id" "--ghc-arg=exceptions-0.10.4" "--ghc-arg=-package-id" "--ghc-arg=filepath-1.4.2.2" "--ghc-arg=-package-id" "--ghc-arg=ptprs-pplctv-0.16.1.0-fec7c138" "--ghc-arg=-package-id" "--ghc-arg=prcss-1.6.14.0-e25bc31e" "--ghc-arg=-package-id" "--ghc-arg=transformers-0.5.6.2" "cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.test.hs" "--builddir" "/Users/infrmtcs/haskell/cabal/dist-newstyle/build/x86_64-osx/ghc-9.2.2/cabal-testsuite-3" "cabal-testsuite/PackageTests/Regression/T6961/Test/cabal.test.hs" "--with-cabal" "/Users/infrmtcs/.ghcup/bin/cabal" (exit 1): failed

@phadej
Copy link
Collaborator

phadej commented Mar 28, 2022

This is by design and mentioned in https://cabal.readthedocs.io/en/3.6/file-format-changelog.html

Dependencies to sublibraries have to be specified explicitly, even for current package. This way you can have an internal library with the same name as some external dependency.

I.e. build-depends: issue6961:internal-lib instead of internal-lib.

I'll leave this open, for someone to add an example to the file format changelog.

@infrmtcs
Copy link
Author

Thanks a lot @phadej, this fix works!

@jneira jneira changed the title Be able to add internal libraries to test-suite dependencies when cabal-version is 3.4 or higher How to add internal libraries to test-suite dependencies when cabal-version is 3.4 or higher (add example to cabal file format docs) Mar 28, 2022
@jneira jneira changed the title How to add internal libraries to test-suite dependencies when cabal-version is 3.4 or higher (add example to cabal file format docs) Document how to add internal libraries to test-suite dependencies when cabal-version is 3.4 or higher (add example to cabal file format docs) Dec 25, 2022
@jneira
Copy link
Member

jneira commented Dec 25, 2022

Documented with #8573 so only left an example in cabal file format changelog

jneira added a commit that referenced this issue Dec 25, 2022
jneira added a commit that referenced this issue Dec 28, 2022
@mergify mergify bot closed this as completed in #8642 Dec 28, 2022
@andreasabel andreasabel added the re: internal library Concerning internal libraries in packages label Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants