From aa5164313aa86941bf15722936824dfbf556a911 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Fri, 7 Jun 2019 16:05:52 -0400
Subject: [PATCH] testsuite: Mark T3372 as fragile on Windows

On Windows we must lock package databases even when opening for
read-only access. This means that concurrent GHC sessions are very
likely to fail with file lock contention.

See #16773.
---
 libraries/ghc-boot/GHC/PackageDb.hs    | 2 ++
 testsuite/tests/ghci/linking/dyn/all.T | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libraries/ghc-boot/GHC/PackageDb.hs b/libraries/ghc-boot/GHC/PackageDb.hs
index c7984d0edb27..31073711d490 100644
--- a/libraries/ghc-boot/GHC/PackageDb.hs
+++ b/libraries/ghc-boot/GHC/PackageDb.hs
@@ -387,6 +387,8 @@ decodeFromFile :: FilePath -> DbOpenMode mode t -> Get pkgs ->
                   IO (pkgs, DbOpenMode mode PackageDbLock)
 decodeFromFile file mode decoder = case mode of
   DbOpenReadOnly -> do
+  -- Note [Locking package database on Windows]
+  -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   -- When we open the package db in read only mode, there is no need to acquire
   -- shared lock on non-Windows platform because we update the database with an
   -- atomic rename, so readers will always see the database in a consistent
diff --git a/testsuite/tests/ghci/linking/dyn/all.T b/testsuite/tests/ghci/linking/dyn/all.T
index 75b1635dd020..46ba064c1726 100644
--- a/testsuite/tests/ghci/linking/dyn/all.T
+++ b/testsuite/tests/ghci/linking/dyn/all.T
@@ -45,5 +45,11 @@ test('big-obj', [extra_files(['big-obj-c.c', 'big-obj.hs']),
                     unless(doing_ghci, skip), unless(opsys('mingw32'), skip)],
      makefile_test, ['big-obj'])
 
-test('T3372', [unless(doing_ghci, skip), extra_run_opts('"' + config.libdir + '"')],
+test('T3372',
+     [unless(doing_ghci, skip),
+      extra_run_opts('"' + config.libdir + '"'),
+      # Concurrent GHC sessions is fragile on Windows since we must lock the
+      # package database even for read-only access.
+      # See Note [Locking package database on Windows] in GHC.PackageDb
+      when(opsys('mingw32'), fragile(16773))],
      compile_and_run, ['-package ghc'])
-- 
GitLab