-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to skip printing skipped tests #516
Open
rynoV
wants to merge
1
commit into
haf:main
Choose a base branch
from
Auspice-Capital:skipped-test-print-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cherry picked from commit 79f6e21)
Hmm. It feels like something the existing Printer argument should be able to handle. Something like this let skipPrinter =
{
TestPrinters.defaultPrinter with
beforeEach = (fun (test) ->
match test.shouldSkipEvaluation with
| None -> TestPrinters.beforeEach test
| Some -> ())
}
runTestsWithCLIArgs [CLIArguments.Printer skipPrinter] argv tests
|
That works. One thing about changing the printer is it seems to break the visual studio adapter, for example when I run in Jetbrains Rider I get an exception from I believe reflection failing: Exception
|
Here's the patch
Index: Expecto/Expecto.fs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Expecto/Expecto.fs b/Expecto/Expecto.fs
--- a/Expecto/Expecto.fs (revision ec1eb970d9e73d3f48c197ceedd851f5eb10ad39)
+++ b/Expecto/Expecto.fs (date 1736273834444)
@@ -449,8 +449,6 @@
| Colours of int
/// Adds a test printer.
| Printer of TestPrinters
- /// Whether to show skipped tests in the output.
- | PrintSkippedTests of bool
/// Sets the verbosity level.
| Verbosity of LogLevel
/// Append a summary handler.
Index: Expecto/CSharp.fs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Expecto/CSharp.fs b/Expecto/CSharp.fs
--- a/Expecto/CSharp.fs (revision ec1eb970d9e73d3f48c197ceedd851f5eb10ad39)
+++ b/Expecto/CSharp.fs (date 1736274464043)
@@ -13,7 +13,7 @@
// C# is weak and can't really handle Async or partial application
type ITestPrinter =
abstract member BeforeRun : Test -> Task
- abstract member BeforeEach : string -> Task
+ abstract member BeforeEach : name: string * enabled: bool -> Task
abstract member Info : string -> Task
abstract member Passed : string * TimeSpan -> Task
abstract member Ignored : string * string -> Task
@@ -28,7 +28,7 @@
let private printerFromInterface (i : ITestPrinter) =
{ beforeRun = fun t -> async { return! i.BeforeRun(t) |> Async.AwaitTask }
- beforeEach = fun s -> async { return! i.BeforeEach(s) |> Async.AwaitTask }
+ beforeEach = fun s e -> async { return! i.BeforeEach(s, e) |> Async.AwaitTask }
passed = fun n d -> async { return! i.Passed(n, d) |> Async.AwaitTask }
info = fun s -> async { return! i.Info(s) |> Async.AwaitTask }
ignored = fun n m -> async { return! i.Ignored(n, m) |> Async.AwaitTask }
Index: Expecto.Tests.CSharp/Tests.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Expecto.Tests.CSharp/Tests.cs b/Expecto.Tests.CSharp/Tests.cs
--- a/Expecto.Tests.CSharp/Tests.cs (revision ec1eb970d9e73d3f48c197ceedd851f5eb10ad39)
+++ b/Expecto.Tests.CSharp/Tests.cs (date 1736272442448)
@@ -10,7 +10,7 @@
{
public class CSharpPrinter : ITestPrinter
{
- Task ITestPrinter.BeforeEach(string value)
+ Task ITestPrinter.BeforeEach(string value, bool enabled)
{
return Task.CompletedTask;
}
Index: Expecto/Expecto.Impl.fs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Expecto/Expecto.Impl.fs b/Expecto/Expecto.Impl.fs
--- a/Expecto/Expecto.Impl.fs (revision ec1eb970d9e73d3f48c197ceedd851f5eb10ad39)
+++ b/Expecto/Expecto.Impl.fs (date 1736274398337)
@@ -207,8 +207,8 @@
type TestPrinters =
{ /// Called before a test run (e.g. at the top of your main function)
beforeRun: Test -> Async<unit>
- /// Called before atomic test (TestCode) is executed.
- beforeEach: string -> Async<unit>
+ /// test name -> enabled -> unit. Called before a test is executed (when enabled = true) or skipped (when enabled = false)
+ beforeEach: string -> bool -> Async<unit>
/// info
info: string -> Async<unit>
/// test name -> time taken -> unit
@@ -232,7 +232,7 @@
static member silent =
{ beforeRun = fun _ -> async.Zero()
- beforeEach = fun _ -> async.Zero()
+ beforeEach = fun _ _ -> async.Zero()
info = fun _ -> async.Zero()
passed = fun _ _ -> async.Zero()
ignored = fun _ _ -> async.Zero()
@@ -244,7 +244,7 @@
{ beforeRun = fun _tests ->
logger.logWithAck Info (eventX "EXPECTO? Running tests...")
- beforeEach = fun n ->
+ beforeEach = fun n _ ->
logger.logWithAck Debug (
eventX "{testName} starting..."
>> setField "testName" n)
@@ -404,8 +404,8 @@
tcLog "testSuiteStarted" [
"name", "ExpectoTestSuite" ] }
- beforeEach = fun n -> async {
- do! innerPrinter.beforeEach n
+ beforeEach = fun n e -> async {
+ do! innerPrinter.beforeEach n e
tcLog "testStarted" [
"flowId", formatName n
"name", formatName n ] }
@@ -439,7 +439,7 @@
"duration", d.TotalMilliseconds |> int |> string ] }
exn = fun n e d -> async {
- do! innerPrinter.beforeEach n
+ do! innerPrinter.beforeEach n true
tcLog "testFailed" [
"flowId", formatName n
"name", formatName n
@@ -460,7 +460,7 @@
do! b
}
{ beforeRun = fun _tests -> runTwoAsyncs (first.beforeRun _tests) (second.beforeRun _tests)
- beforeEach = fun n -> runTwoAsyncs (first.beforeEach n) (second.beforeEach n)
+ beforeEach = fun n e -> runTwoAsyncs (first.beforeEach n e) (second.beforeEach n e)
info = fun s -> runTwoAsyncs (first.info s) (second.info s)
passed = fun n d -> runTwoAsyncs (first.passed n d) (second.passed n d)
ignored = fun n m -> runTwoAsyncs (first.ignored n m) (second.ignored n m)
@@ -498,8 +498,6 @@
listStates : FocusState list
/// Allows the test printer to be parametised to your liking.
printer : TestPrinters
- /// Whether to show skipped tests in the output.
- printSkippedTests : bool
/// Verbosity level (default: Info).
verbosity : LogLevel
/// Process name to log under (default: "Expecto")
@@ -538,7 +536,6 @@
TestPrinters.defaultPrinter
else
TestPrinters.teamCityPrinter TestPrinters.defaultPrinter
- printSkippedTests = true
verbosity = Info
logName = None
locate = fun _ -> SourceLocation.empty
@@ -651,18 +648,15 @@
let beforeEach (test:FlatTest) =
let name = config.joinWith.format test.name
- if config.printSkippedTests || test.shouldSkipEvaluation.IsNone then
- config.printer.beforeEach name
- else
- async.Zero()
+
+ config.printer.beforeEach name <| Option.isNone test.shouldSkipEvaluation
async {
let! beforeAsync = beforeEach test |> Async.StartChild
let! result = execTestAsync ct config test
do! beforeAsync
- if config.printSkippedTests || test.shouldSkipEvaluation.IsNone then
- do! TestPrinters.printResult config test result
+ do! TestPrinters.printResult config test result
if progressStarted && Option.isNone test.shouldSkipEvaluation then
Fraction (Interlocked.Increment testsCompleted, testLength)
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #453
Separated out from #511