Skip to content

Flaky test: help_options baseline fails due to global mutable enableConsoleColoring #19384

@T-Gro

Description

@T-Gro

Summary

The CompilerOptions.Fsc.help_options.Help tests (variants 1-3) intermittently fail on Linux CI because the --consolecolors default shows (off by default) instead of the baseline's (on by default).

Root cause

enableConsoleColoring is a global mutable (let mutable enableConsoleColoring = true in src/Compiler/Driver/CompilerOptions.fs:510). The FscOptionTests.fs test at line 57-61 exercises --consolecolors-, which sets this global to false. Since checker.Compile runs in-process, the mutation persists across tests.

When help_options runs after the --consolecolors- test, enableConsoleColoring is still false, so the help output says (off by default) instead of (on by default), mismatching the baseline.

Reproduction

The failure depends on xUnit test execution order. It reproduces consistently on Linux CI but not locally (different parallelism/ordering). Observed on PR #19021 across multiple CI runs.

Relevant code

  • Global mutable: src/Compiler/Driver/CompilerOptions.fs:510
  • Help text generation: src/Compiler/Driver/CompilerOptions.fs:884 — reads enableConsoleColoring at format time
  • Mutating test: tests/FSharp.Compiler.ComponentTests/CompilerOptions/Fsc/FscOptionTests.fs:57-61
  • Failing test: tests/FSharp.Compiler.ComponentTests/CompilerOptions/Fsc/misc/misc.fs:15-44
  • Baseline: tests/FSharp.Compiler.ComponentTests/CompilerOptions/Fsc/misc/compiler_help_output.bsl

Possible fixes

  1. Reset enableConsoleColoring = true before each help_options test
  2. Save/restore the global in FscOptionTests after exercising --consolecolors-
  3. Longer term: eliminate the global mutable by threading the setting through TcConfigBuilder

Metadata

Metadata

Assignees

Type

No type

Projects

Status

New

Relationships

None yet

Development

No branches or pull requests

Issue actions