From 11063a8be5d98295a9c93f7dfc5469ba46f73167 Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Mon, 22 Jul 2024 23:39:41 +0200 Subject: [PATCH] Add tests for unsupported builds on Windows --- .gitignore | 1 + .../PackageTests/NoOSSupport/DynExe/Main.hs | 4 ++++ .../PackageTests/NoOSSupport/DynExe/a.cabal | 8 ++++++++ .../PackageTests/NoOSSupport/DynExe/cabal.out | 10 ++++++++++ .../PackageTests/NoOSSupport/DynExe/cabal.test.hs | 5 +++++ .../PackageTests/NoOSSupport/RelocatableExe/Main.hs | 4 ++++ .../PackageTests/NoOSSupport/RelocatableExe/a.cabal | 8 ++++++++ .../PackageTests/NoOSSupport/RelocatableExe/cabal.out | 10 ++++++++++ .../NoOSSupport/RelocatableExe/cabal.test.hs | 5 +++++ cabal-testsuite/src/Test/Cabal/Prelude.hs | 3 +++ 10 files changed, 58 insertions(+) create mode 100644 cabal-testsuite/PackageTests/NoOSSupport/DynExe/Main.hs create mode 100644 cabal-testsuite/PackageTests/NoOSSupport/DynExe/a.cabal create mode 100644 cabal-testsuite/PackageTests/NoOSSupport/DynExe/cabal.out create mode 100644 cabal-testsuite/PackageTests/NoOSSupport/DynExe/cabal.test.hs create mode 100644 cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/Main.hs create mode 100644 cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/a.cabal create mode 100644 cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/cabal.out create mode 100644 cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/cabal.test.hs diff --git a/.gitignore b/.gitignore index f2568f428f8..783d3862eec 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,7 @@ register.sh # listed explicitly to show which files are generated but ignored testdb/intree/cabal.project-test testdb/intree/store/**/bin/alex +testdb/intree/store/**/bin/alex.exe testdb/intree/store/**/cabal-hash.txt testdb/intree/store/**/share/AlexTemplate.hs testdb/intree/store/**/share/AlexWrappers.hs diff --git a/cabal-testsuite/PackageTests/NoOSSupport/DynExe/Main.hs b/cabal-testsuite/PackageTests/NoOSSupport/DynExe/Main.hs new file mode 100644 index 00000000000..6f2b80aa9ed --- /dev/null +++ b/cabal-testsuite/PackageTests/NoOSSupport/DynExe/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/cabal-testsuite/PackageTests/NoOSSupport/DynExe/a.cabal b/cabal-testsuite/PackageTests/NoOSSupport/DynExe/a.cabal new file mode 100644 index 00000000000..58868453b6b --- /dev/null +++ b/cabal-testsuite/PackageTests/NoOSSupport/DynExe/a.cabal @@ -0,0 +1,8 @@ +cabal-version: 3.0 +name: aa +version: 0.1.0.0 +build-type: Simple + +executable a + default-language: Haskell2010 + main-is: Main.hs diff --git a/cabal-testsuite/PackageTests/NoOSSupport/DynExe/cabal.out b/cabal-testsuite/PackageTests/NoOSSupport/DynExe/cabal.out new file mode 100644 index 00000000000..8d849b87e96 --- /dev/null +++ b/cabal-testsuite/PackageTests/NoOSSupport/DynExe/cabal.out @@ -0,0 +1,10 @@ +# cabal build +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following will be built: + - aa-0.1.0.0 (exe:a) (first run) +Configuring executable 'a' for aa-0.1.0.0... +Error: [Cabal-3339] +Operating system: windows, does not support shared executables +Error: [Cabal-7125] +Failed to build aa-0.1.0.0-inplace-a. The failure occurred during the configure step. diff --git a/cabal-testsuite/PackageTests/NoOSSupport/DynExe/cabal.test.hs b/cabal-testsuite/PackageTests/NoOSSupport/DynExe/cabal.test.hs new file mode 100644 index 00000000000..396de4e04b1 --- /dev/null +++ b/cabal-testsuite/PackageTests/NoOSSupport/DynExe/cabal.test.hs @@ -0,0 +1,5 @@ +import Test.Cabal.Prelude + +main = do + skipUnlessWindows + cabalTest $ fails $ cabal "build" ["--enable-executable-dynamic"] diff --git a/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/Main.hs b/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/Main.hs new file mode 100644 index 00000000000..6f2b80aa9ed --- /dev/null +++ b/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/a.cabal b/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/a.cabal new file mode 100644 index 00000000000..58868453b6b --- /dev/null +++ b/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/a.cabal @@ -0,0 +1,8 @@ +cabal-version: 3.0 +name: aa +version: 0.1.0.0 +build-type: Simple + +executable a + default-language: Haskell2010 + main-is: Main.hs diff --git a/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/cabal.out b/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/cabal.out new file mode 100644 index 00000000000..f59d29e6b17 --- /dev/null +++ b/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/cabal.out @@ -0,0 +1,10 @@ +# cabal build +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following will be built: + - aa-0.1.0.0 (exe:a) (first run) +Configuring executable 'a' for aa-0.1.0.0... +Error: [Cabal-3339] +Operating system: windows, does not support relocatable builds +Error: [Cabal-7125] +Failed to build aa-0.1.0.0-inplace-a. The failure occurred during the configure step. diff --git a/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/cabal.test.hs b/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/cabal.test.hs new file mode 100644 index 00000000000..448fc6fc22a --- /dev/null +++ b/cabal-testsuite/PackageTests/NoOSSupport/RelocatableExe/cabal.test.hs @@ -0,0 +1,5 @@ +import Test.Cabal.Prelude + +main = do + skipUnlessWindows + cabalTest $ fails $ cabal "build" ["--enable-relocatable"] diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs index 80653c49f3a..c9a975e0fb7 100644 --- a/cabal-testsuite/src/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs @@ -937,6 +937,9 @@ isJavaScript = buildArch == JavaScript skipIfWindows :: String -> IO () skipIfWindows why = skipIfIO ("Windows " <> why) isWindows +skipUnlessWindows :: IO () +skipUnlessWindows = skipIfIO "Only interesting in Windows" (not isWindows) + getOpenFilesLimit :: TestM (Maybe Integer) #ifdef mingw32_HOST_OS -- No MS-specified limit, was determined experimentally on Windows 10 Pro x64,