Skip to content

Conversation

@stscoundrel
Copy link
Contributor

In test output, there were some confusing "duplicated" test cases being run. Upon closer inspection they were not duplicates, but their names were somewhat misleading.

  • Castling tests: there was duplicate "queen side" test, where the other was in fact "king side" test incorrectly named
  • Pawn tests: there was "duplicate" for every test, but apparently first ones were white pawn tests and latter ones black pawn tests. Rename them to give clear output which one is being tested.

While checking these, I also added additional castling tests. Nothing of note was revealed through them, but adds a bit of coverage for different scenarios.

  • Bishop variant of threat. Sibling to current knight/rook tests.
  • Threat on rooks trip during castling move.

Previously pawn tests seemed "duplicated", as the test output was something like:

chess.PawnTest:
  + move towards rank by 1 square 0.143s
  + not move to positions that are occupied by the same color 0.0s
  + capture in diagonal 0.001s
  + require a capture to move in diagonal 0.0s
  + move towards rank by 2 squares 0.002s
  + capture en passant 0.004s
  + move towards rank by 1 square-1 0.001s
  + not move to positions that are occupied by the same color-1 0.0s
  + capture in diagonal-1 0.001s
  + require a capture to move in diagonal-1 0.0s
  + move towards rank by 2 squares-1 0.002s
  + capture en passant-1 0.001s

By a quick glance it seemed the test were identical duplicates. However, the first ones were white pawn variants and latter ones were black pawn variants.

Rename the tests to include note on which one they're testing. The new test output is something like:

chess.PawnTest:
  + move towards rank by 1 square (white pawn) 0.163s
  + not move to positions that are occupied by the same color (white pawn) 0.001s
  + capture in diagonal (white pawn) 0.002s
  + require a capture to move in diagonal (white pawn) 0.0s
  + move towards rank by 2 squares (white pawn) 0.002s
  + capture en passant (white pawn) 0.004s
  + move towards rank by 1 square (black pawn) 0.001s
  + not move to positions that are occupied by the same color (black pawn) 0.0s
  + capture in diagonal (black pawn) 0.001s
  + require a capture to move in diagonal (black pawn) 0.0s
  + move towards rank by 2 squares (black pawn) 0.003s
  + capture en passant (black pawn) 0.004s
In test output, it seemed there were two instances of the same test:

+ threat on rook does not prevent castling king side 0.003s
+ threat on rook does not prevent castling king side-1 0.001s

In fact the latter one was queens side test with copypaste name
@lenguyenthanh
Copy link
Member

lenguyenthanh commented Apr 6, 2024

Thank you for the contribution!

These changes are indeed improve these tests situations.

I'm actually thinking about removing these legacy tests. Because We have better tests coverage with Bitboard and perft tests. But in the other hands, why not just keep them so 🤷 .

@lenguyenthanh lenguyenthanh merged commit 2988482 into lichess-org:master Apr 6, 2024
@stscoundrel
Copy link
Contributor Author

Interesting to know, @lenguyenthanh. If there is division between the new and old styles of tests, perhaps is it mentioned somewhere? From observing the tests alone it is not clear if some part is becoming legacy or not.

@stscoundrel stscoundrel deleted the chore-test-cleanup branch April 6, 2024 13:46
@lenguyenthanh
Copy link
Member

Hey, sorry for the late reply!

Unfortunately, that there is no clear division between new and legacy tests (and there is no documents :( sorry for that). It requires a bit of involving (historically) with this library and this is also just my personal opinion.

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