Skip to content

Commit bbd2bf7

Browse files
committed
Add test to check global extra-prog-path is used in configureCompiler
We add a new PackageTest for cabal-install, which makes sure that the extra-prog-path in the global config is used when resolving pkg-config instead of anything already on PATH. We do this by specifying a "bad" pkg-config to extra-prog-path that returns exit code 1. On Windows, Cabal logs are identical in the following two cases: - the override didn't work, and pkg-config was not found on the system - the override did work, and querying it failed (expectedly) To work around this, we add a "good" pkg-config script to PATH before- hand, so that cabal succeeds in the first case and the logs differ. This test is a stripped down reproduction of what happens when a user on Windows adds MSYS2 paths to extra-prog-path but not the system PATH. This is a reasonable setup (often, adding MSYS2 to system PATH is not good practice), and is even created automatically by GHCup.
1 parent 7ee0d49 commit bbd2bf7

File tree

11 files changed

+152
-0
lines changed

11 files changed

+152
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module MyLibrary () where
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: *.cabal
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CheckExtraProgPathGlobal
2+
version: 0.1
3+
license: BSD3
4+
license-file: LICENSE
5+
author: Yuto Takano
6+
maintainer: Yuto Takano
7+
synopsis: Check Extra Prog Path Global
8+
category: PackageTests
9+
build-type: Simple
10+
cabal-version: 2.0
11+
12+
description:
13+
Check that Cabal recognizes an override of the prog path.
14+
15+
Library
16+
pkgconfig-depends: zlib
17+
default-language: Haskell2010
18+
build-depends: base <5.0
19+
exposed-modules:
20+
MyLibrary
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
# ugly, but "good enough" for this test
6+
# This will need to be updated whenever cabal invokes pkg-config
7+
# in new ways
8+
case "$*" in
9+
'--version')
10+
echo 2.1.0 # whatever
11+
;;
12+
13+
'--variable pc_path pkg-config')
14+
echo '.'
15+
;;
16+
17+
'--list-all')
18+
printf 'zlib zlib - zlib compression library\n'
19+
# \256 = \xAE is the iso-8859-1 (latin-1) encoded version of U+00AE,
20+
# i.e. the "registered sign": ®
21+
# This resulted in problems, see #9608
22+
printf 'vpl Intel\256 Video Processing Library - Accelerated video decode, encode, and frame processing capabilities on Intel\256 GPUs\n'
23+
# \360 = \xF0 is latin-1 for ð; this is orð, Icelandic for "word"/"words".
24+
printf 'or\360 Icelandic characters\n'
25+
;;
26+
27+
'--modversion '*)
28+
shift # drop the --modversion
29+
for arg; do
30+
case "$arg" in
31+
zlib) echo 1.3; ;; # whatever
32+
vpl) echo 2.10; ;; # whatever
33+
# No entry for orð here; let's not even try to match on that
34+
*)
35+
echo >&2 "Package $arg was not found in the pkg-config search path."
36+
exit 1
37+
esac
38+
done
39+
;;
40+
41+
# Ignore some stuff we're not implementing
42+
'--cflags '*) ;;
43+
'--libs '*) ;;
44+
45+
*)
46+
echo >&2 "pkg-config: unrecognised arguments $* (this is an incomplete shim)"
47+
exit 1
48+
;;
49+
esac
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH/sh.exe"
2+
args = "SCRIPTSWINPATHDIR/pkg-config"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
exit 1;
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path = "FINDSH/sh.exe"
2+
args = "SCRIPTSDIR/pkg-config"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# cabal v2-build
2+
Configuration is affected by the following files:
3+
- cabal.project
4+
Warning: cannot determine version of <ROOT>/scripts/pkg-config :
5+
""
6+
Warning: cannot determine version of <ROOT>/scripts/pkg-config :
7+
""
8+
Resolving dependencies...
9+
Error: [Cabal-7107]
10+
Could not resolve dependencies:
11+
[__0] next goal: CheckExtraProgPathGlobal (user goal)
12+
[__0] rejecting: CheckExtraProgPathGlobal-0.1 (pkg-config package zlib-any is needed but no pkg-config executable was found or querying it failed)
13+
[__0] fail (backjumping, conflict set: CheckExtraProgPathGlobal)
14+
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: CheckExtraProgPathGlobal (2)

0 commit comments

Comments
 (0)