From 8bef8d9ff72ca826338e2e893b0d97bfc7b25d0b Mon Sep 17 00:00:00 2001
From: Luite Stegeman <stegeman@gmail.com>
Date: Wed, 13 Dec 2023 14:22:14 +0100
Subject: [PATCH] JS: Mark spurious CI failures js_fragile(24259)

This marks the spurious test failures on the JS platform as
js_fragile(24259), so we don't hold up merge requests while
fixing the underlying issues.

See #24259
---
 libraries/base/tests/all.T                      | 2 +-
 testsuite/driver/testlib.py                     | 7 +++++++
 testsuite/tests/backpack/cabal/T20509/all.T     | 1 +
 testsuite/tests/backpack/cabal/bkpcabal02/all.T | 3 ++-
 testsuite/tests/backpack/cabal/bkpcabal03/all.T | 3 ++-
 testsuite/tests/concurrent/should_run/all.T     | 2 +-
 testsuite/tests/ghc-api/downsweep/all.T         | 1 +
 testsuite/tests/numeric/should_run/all.T        | 4 ++--
 testsuite/tests/rts/all.T                       | 1 +
 9 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T
index d10182cb484e..1a7ebed8aafe 100644
--- a/libraries/base/tests/all.T
+++ b/libraries/base/tests/all.T
@@ -309,7 +309,7 @@ test('listThreads', normal, compile_and_run, [''])
 test('listThreads1', omit_ghci, compile_and_run, [''])
 test('inits1tails1', normal, compile_and_run, [''])
 test('CLC149', normal, compile, [''])
-test('AtomicModifyIORef', normal, compile_and_run, [''])
+test('AtomicModifyIORef', js_fragile(24259), compile_and_run, [''])
 test('AtomicSwapIORef', normal, compile_and_run, [''])
 test('T23454', normal, compile_fail, [''])
 test('T23687', normal, compile_and_run, [''])
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index bc8116a5374c..e6f3dff486ee 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -153,6 +153,13 @@ def js_broken( bug: IssueNumber ):
     else:
         return normal;
 
+# expect occasional failures for the JS backend
+def js_fragile( bug: IssueNumber ):
+    if js_arch():
+        return fragile(bug);
+    else:
+        return normal;
+
 def expect_fail( name, opts ):
     # The compiler, testdriver, OS or platform is missing a certain
     # feature, and we don't plan to or can't fix it now or in the
diff --git a/testsuite/tests/backpack/cabal/T20509/all.T b/testsuite/tests/backpack/cabal/T20509/all.T
index b5ee1fa0cd4a..18443481bfbf 100644
--- a/testsuite/tests/backpack/cabal/T20509/all.T
+++ b/testsuite/tests/backpack/cabal/T20509/all.T
@@ -1,6 +1,7 @@
 test('T20509',
      [extra_files(['p', 'q', 'T20509.cabal', 'Setup.hs'])
      , run_timeout_multiplier(2)
+     , js_fragile(24259)
      ],
      makefile_test,
      [])
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/all.T b/testsuite/tests/backpack/cabal/bkpcabal02/all.T
index 8635e762fd35..2b5e3e70f0f2 100644
--- a/testsuite/tests/backpack/cabal/bkpcabal02/all.T
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/all.T
@@ -1,5 +1,6 @@
 test('bkpcabal02',
      [extra_files(['p', 'q', 'bkpcabal02.cabal', 'Setup.hs']),
-      normalise_version('bkpcabal01')],
+      normalise_version('bkpcabal01'),
+      js_fragile(24259)],
      makefile_test,
      [])
diff --git a/testsuite/tests/backpack/cabal/bkpcabal03/all.T b/testsuite/tests/backpack/cabal/bkpcabal03/all.T
index b3ad08af5d0c..1c79f871b7fd 100644
--- a/testsuite/tests/backpack/cabal/bkpcabal03/all.T
+++ b/testsuite/tests/backpack/cabal/bkpcabal03/all.T
@@ -1,4 +1,5 @@
 test('bkpcabal03',
-     [extra_files(['asig1', 'asig2', 'bkpcabal03.cabal.in1', 'bkpcabal03.cabal.in2', 'Setup.hs', 'Mod.hs'])],
+     [extra_files(['asig1', 'asig2', 'bkpcabal03.cabal.in1', 'bkpcabal03.cabal.in2', 'Setup.hs', 'Mod.hs']),
+      js_fragile(24259)],
      makefile_test,
      [])
diff --git a/testsuite/tests/concurrent/should_run/all.T b/testsuite/tests/concurrent/should_run/all.T
index b1c9d42daf91..c11724ab3bce 100644
--- a/testsuite/tests/concurrent/should_run/all.T
+++ b/testsuite/tests/concurrent/should_run/all.T
@@ -47,7 +47,7 @@ test('T3429', [ extra_run_opts('+RTS -C0.001 -RTS'),
 # times out with ghci
 test('T4030', omit_ghci, compile_and_run, ['-O'])
 
-test('throwto002', normal, compile_and_run, [''])
+test('throwto002', js_fragile(24259), compile_and_run, [''])
 test('throwto003', normal, compile_and_run, [''])
 
 test('mask001', normal, compile_and_run, [''])
diff --git a/testsuite/tests/ghc-api/downsweep/all.T b/testsuite/tests/ghc-api/downsweep/all.T
index 75de163b9e7f..bb1c02db1338 100644
--- a/testsuite/tests/ghc-api/downsweep/all.T
+++ b/testsuite/tests/ghc-api/downsweep/all.T
@@ -3,6 +3,7 @@ setTestOpts(when(arch('wasm32'), run_timeout_multiplier(2)))
 test('PartialDownsweep',
      [ extra_run_opts('"' + config.libdir + '"')
      , ignore_stderr
+     , js_fragile(24259)
      ],
      compile_and_run,
      ['-package ghc -package exceptions'])
diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T
index 074155bb6ec8..acbca8e76582 100644
--- a/testsuite/tests/numeric/should_run/all.T
+++ b/testsuite/tests/numeric/should_run/all.T
@@ -79,6 +79,6 @@ test('IntegerToFloat', normal, compile_and_run, [''])
 
 test('T20291', normal, compile_and_run, [''])
 test('T22282', normal, compile_and_run, [''])
-test('T22671', normal, compile_and_run, [''])
-test('foundation', [when(js_arch(), run_timeout_multiplier(2))], compile_and_run, ['-O -package transformers'])
+test('T22671', js_fragile(24259), compile_and_run, [''])
+test('foundation', [when(js_arch(), run_timeout_multiplier(2)), js_fragile(24259)], compile_and_run, ['-O -package transformers'])
 test('T24066', normal, compile_and_run, [''])
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index cc0995b5b315..d89a9d82e599 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -302,6 +302,7 @@ test('T7919', [ when(fast(), skip)
               , omit_ghci
               , req_th
               , when(platform('x86_64-unknown-linux'), fragile(22283))
+              , js_fragile(24259)
               ]
               , compile_and_run, [config.ghc_th_way_flags])
 
-- 
GitLab