Skip to content
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

Alphametics tests to handle timeouts for longer tests #1029

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

martinfreedman
Copy link

Changed alphameticstests.fs to make all tests async and added xunit Timeout attribute to longest 3 tests with 2 secs for Puzzle with eight letters and 5 seconds each for Puzzle with ten letters and 199 addends and Puzzle with ten letters exercises.

And switch back on testrunner for this exercise.

Changed alphameticstests.fs to make all tests async and added xunit Timeout attribute to longest 3 tests with 2 secs for ``Puzzle with eight letters`` and 5 seconds each for ``Puzzle with ten letters and 199 addends`` and ``Puzzle with ten letters`` exercises.
@martinfreedman martinfreedman mentioned this pull request Nov 8, 2021

[<Fact(Skip = "Remove this Skip property to run this test")>]
let ``Puzzle with eight letters`` () =
[<Fact(Timeout=2000,Skip = "Remove this Skip property to run this test")>]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea. The actual timeouts are slightly tricky to determine, but I'm fine with having some value here. That said, we currently can't merge this as the test runner will strip the attribute before it runs the tests:

type EnableAllTests() =
    inherit SyntaxVisitor()

    override _.VisitSynAttribute(attr: SynAttribute) : SynAttribute =
        match attr.TypeName with
        | LongIdentWithDots ([ ident ], _) when ident.idText = "Fact" ->
            base.VisitSynAttribute
                { attr with
                      ArgExpr = SynExpr.Const(SynConst.Unit, attr.ArgExpr.Range) }
        | _ -> base.VisitSynAttribute(attr)

Would you be interested in fixing that too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup will have a look at that shortly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look at this. Which repo and file is it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think timeouts should be discussed at the practise exercise specification, hence my other PR to update canonical json with a timeout property. This might include relative timings between tests as implied here between 8 versus 10 letter tests. The actual implementation would depend on the track maintainers factoring in the built in online test runner timeouts and language performance etc. I would probably default to 10 seconds per test, a propos of anything more specific.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already wrote a reply but it has inexplicably disappeared. What files do I need to look at?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1029 (comment). I should have posted that comment here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinfreedman Let me know if you need any help/pointers. The F# syntax tree can be tricky to work with.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. And yes the Diamond exercise does not use [<Fact>]! I will add this into my solution when I have a chance (I have Covid right now). Any other exercises tests with non-standard Attributes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I have Covid right now)

Oh no! All the best.

Any other exercises tests with non-standard Attributes?

The simple-linked-list exercise uses a [<Theory>] attribute (which should actually be converted to multiple [<Fact>] attributes.

@ErikSchierboom
Copy link
Member

Which repo and file is it?

This one: https://github.com/exercism/fsharp-test-runner/blob/main/src/Exercism.TestRunner.FSharp/Rewrite.fs#L20

I think timeouts should be discussed at the practise exercise specification, hence my other PR to update canonical json with a timeout property. This might include relative timings between tests as implied here between 8 versus 10 letter tests. The actual implementation would depend on the track maintainers factoring in the built in online test runner timeouts and language performance etc. I would probably default to 10 seconds per test, a propos of anything more specific.

I'm not entirely sure about the timeouts being in the prob-specs definition, but I'll post my thoughts there.

Oh and I completely forgot to mention that the alphametics exercise's test file is automatically generated by a test generator: https://github.com/exercism/fsharp/blob/main/generators/Generators.fs#L61 That means that any changes that are not made to the generator would be overwritten when we re-generate the tests. I think you can ignore that for now, as the F# test generator hasn't yet been updated to use the tests.toml file (I started working on that), but I did want to mention it.

@ErikSchierboom
Copy link
Member

Speaking of the tests.toml file, that would be a great place to configure these timeouts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants