Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove duplicated tests that are no longer necessary #224

Merged
merged 3 commits into from
Sep 2, 2024

Conversation

rebecca-thompson
Copy link
Contributor

@rebecca-thompson rebecca-thompson commented Jun 22, 2023

What does this change?

Support for Scala 2.11 was removed here: ab78878. This pr adds tests for Scala 2.13 and removes 2.11 tests.

EDIT: This PR now removes the 2.11 tests entirely, and makes the existing 2.12 tests run for all supported scala versions. This means the repository tests are now run for scala 2.13 as well as for scala 2.12. See messages below for more detail.

How to test

  • Compare sbt "clean; test" on main with this branch: see that the former compiles source code but doesn’t run any tests, whereas the latter compiles code and runs tests
  • Compare sbt "clean; +test" on main with this branch: on main the tests are only run for scala 2.12, but on this branch they’re also run for 2.13.

@rebecca-thompson rebecca-thompson requested a review from a team as a code owner June 22, 2023 13:24
Copy link
Contributor

@emdash-ie emdash-ie left a comment

Choose a reason for hiding this comment

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

This looks good to me: shall we merge tomorrow?

I ran locally to make sure the tests still pass on the PR, and they do. Am I right in my impression that the tests are identical for 2.12 and 2.13, and if so is there any way to do that without requiring the duplicated files? Haven’t looked at tests for specific scala versions before.

@emdash-ie emdash-ie self-requested a review August 30, 2024 09:36
@emdash-ie
Copy link
Contributor

I’ve been looking into this and doing some testing, and it seems that there’s no need to duplicate files: any files in test/scala will be run for all versions requested (e.g. all crossScalaVersions when running +test), so we should only need separate test/scala-2.12 and test/scala-2.13 files when the test source code needs to differ for the different versions.

Here’s the output from my testing, with warnings stripped out to make it clearer what’s going on:

sbt:root> clean; test
[success] Total time: 1 s, completed 30 Aug 2024, 10:31:55
[info] Generating scrooge thrift for /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/content/v1.thrift, /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/events/fastly/event.thrift, /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/events/flexible/auxiliaryAtomEvent.thrift, /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/events/crier/event.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/story-packages-model-thrift/story_package_event.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/story-packages-model-thrift/story_package_article.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/audio.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/timeline.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/guide.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/interactive.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/profile.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/chart.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/qanda.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/email#.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/media.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/cta.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/shared.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/commonsdivision.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/quiz.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/review.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/explainer.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/recipe.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/contentatom.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/shared.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entity.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/restaurant.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/game.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/organisation.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/place.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/person.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/film.thrift ...
[info] compiling 182 Scala sources to /Users/emily_bourke/code/content-api-models/scala/target/scala-2.13/classes ...
[info] done compiling
[info] compiling 3 Scala sources to /Users/emily_bourke/code/content-api-models/json/target/scala-2.13/classes ...
[info] done compiling
[info] compiling 3 Scala sources to /Users/emily_bourke/code/content-api-models/json/target/scala-2.13/test-classes ...
[info] done compiling
[info] CirceRoundTripSpec:
[info] - should run 2.13 tests
[info] CirceRoundTripSpecShared:
[info] - should run non-versioned tests
[info] Run completed in 194 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 2, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 44 s, completed 30 Aug 2024, 10:32:39
sbt:root> clean; +test
[success] Total time: 2 s, completed 30 Aug 2024, 10:26:49
[info] Setting Scala version to 2.12.11 on 6 projects.
[info] Reapplying settings...
[info] set current project to root (in build file:/Users/emily_bourke/code/content-api-models/)
[info] Generating scrooge thrift for /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/content/v1.thrift, /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/events/fastly/event.thrift, /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/events/flexible/auxiliaryAtomEvent.thrift, /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/events/crier/event.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/story-packages-model-thrift/story_package_event.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/story-packages-model-thrift/story_package_article.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/audio.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/timeline.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/guide.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/interactive.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/profile.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/chart.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/qanda.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/email#.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/media.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/cta.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/shared.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/commonsdivision.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/quiz.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/review.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/explainer.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/recipe.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/contentatom.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/shared.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entity.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/restaurant.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/game.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/organisation.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/place.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/person.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/film.thrift ...
[info] compiling 182 Scala sources to /Users/emily_bourke/code/content-api-models/scala/target/scala-2.12/classes ...
[info] done compiling
[info] compiling 3 Scala sources to /Users/emily_bourke/code/content-api-models/json/target/scala-2.12/classes ...
[info] done compiling
[info] compiling 3 Scala sources to /Users/emily_bourke/code/content-api-models/json/target/scala-2.12/test-classes ...
[info] done compiling
[info] CirceRoundTripSpecShared:
[info] - should run non-versioned tests
[info] CirceRoundTripSpec:
[info] - should run 2.12 tests
[info] Run completed in 88 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 2, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 28 s, completed 30 Aug 2024, 10:27:18
[info] Setting Scala version to 2.13.2 on 6 projects.
[info] Reapplying settings...
[info] set current project to root (in build file:/Users/emily_bourke/code/content-api-models/)
[info] Generating scrooge thrift for /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/content/v1.thrift, /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/events/fastly/event.thrift, /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/events/flexible/auxiliaryAtomEvent.thrift, /Users/emily_bourke/code/content-api-models/scala/../models/src/main/thrift/events/crier/event.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/story-packages-model-thrift/story_package_event.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/story-packages-model-thrift/story_package_article.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/audio.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/timeline.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/guide.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/interactive.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/profile.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/chart.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/qanda.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/email#.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/media.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/cta.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/shared.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/commonsdivision.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/quiz.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/review.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/explainer.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/atoms/recipe.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-atom-model-thrift/contentatom.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/shared.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entity.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/restaurant.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/game.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/organisation.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/place.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/person.thrift, /Users/emily_bourke/code/content-api-models/scala/target/thrift_external/content-entity-thrift/entities/film.thrift ...
[info] compiling 182 Scala sources to /Users/emily_bourke/code/content-api-models/scala/target/scala-2.13/classes ...
[info] done compiling
[info] compiling 3 Scala sources to /Users/emily_bourke/code/content-api-models/json/target/scala-2.13/classes ...
[info] done compiling
[info] compiling 3 Scala sources to /Users/emily_bourke/code/content-api-models/json/target/scala-2.13/test-classes ...
[info] done compiling
[info] CirceRoundTripSpec:
[info] - should run 2.13 tests
[info] CirceRoundTripSpecShared:
[info] - should run non-versioned tests
[info] Run completed in 80 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 2, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 32 s, completed 30 Aug 2024, 10:27:50
[info] Reapplying settings...
[info] set current project to root (in build file:/Users/emily_bourke/code/content-api-models/)

So I think we should put all the tests under test/scala, unless they’re intended to be different. I’ll take a look at the commit history now and try to figure out whether they are.

@emdash-ie
Copy link
Contributor

emdash-ie commented Aug 30, 2024

Ok, did some looking through the history! The tests for 2.11 were introduced in #172. It’s a bit hard to see from the diff on github, but the newly-introduced 2.11 tests at that point were almost identical to the 2.12 tests, differing only in the diff-producing code they used (2.12 on the left, 2.11 on the right):

14,18c14
< import diffson._
< import diffson.lcs._
< import diffson.circe._
< import diffson.jsonpatch._
< import diffson.jsonpatch.simplediff._
---
> import gnieh.diffson.circe._
186c182
<     val d = diff(jsonBefore, jsonAfter)
---
>     val d = JsonDiff.diff(jsonBefore, jsonAfter, false)

Since the tests also used different versions of diffson-circe, my guess is that this is something that changed in that library between 3.1.1 and 4.0.0. The difference between the v3 documentation and the current documentation confirms that. 3.1.1 is the latest full version of diffson-circe_2.11, explaining why that version was used for the tests.

On main the tests have drifted a bit further, because I and others updated only the 2.12 tests. Since we no longer support 2.11, I reckon we can go back to having just one version of the tests, using a v4 version of diffson-circe: I will take a look. I also don’t think we should merge this PR as-is just yet.

(Side note: I hadn’t noticed the different dependencies for different scala versions: I will check that this currently makes sense, as I’m worried we may be testing against old fezziwig versions.)

@emdash-ie
Copy link
Contributor

emdash-ie commented Aug 30, 2024

It looks like the current situation is just that the 2.11 tests haven’t been run since that version was removed from crossScalaVersions. There’s also no need for me to worry about not having updated the customDeps bit, because those were removed in 8ab9991.

So, I think all we should do now is remove the 2.11 tests altogether, and make the 2.12 tests run at every scala version by moving them back into test/scala. I’ll update this PR to do that.

rebecca-thompson and others added 3 commits August 30, 2024 13:57
These tests were originally duplicated across two scala versions in
[PR #172](#172), when
new tests were added for scala 2.11. There’s not much info in the PR or
commit history, but it looks like the reason for duplicating the source
code was to use an older version of diffson-circe, where the API is
slightly different (v3 is the last released version for 2.11, so the v4
version in use in the tests at the time couldn’t be used in the 2.11
tests).

Since we now don’t support 2.11 anymore, the test source code doesn’t
need to differ across different scala versions. (On main at the moment
they differ slightly across the 2.12 and 2.11 tests, but only because
recent changes have been made to 2.12 and not 2.11.)

Since sbt runs tests that are not version-specific (e.g. those in
`test/scala` rather than `test/scala-2.x`) for every requested scala
version, there’s no need to duplicate the files when the tests are
intended to be the same.

As such, this commit makes the newer tests not version-specific anymore,
by moving them back to json/src/test/scala, deleting the second copy.
@emdash-ie
Copy link
Contributor

Since I’ve made changes, I’ll get someone else to review it rather than relying on my own earlier review.

@emdash-ie emdash-ie requested a review from a team August 30, 2024 12:59
@emdash-ie emdash-ie changed the title Add tests for Scala 2.13 and remove tests for Scala 2.11 Remove duplicated tests that are no longer necessary Aug 30, 2024
Copy link
Contributor

@jonathonherbert jonathonherbert left a comment

Choose a reason for hiding this comment

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

So, I think all we should do now is remove the 2.11 tests altogether, and make the 2.12 tests run at every scala version by moving them back into test/scala. I’ll update this PR to do that.

Agreed! ✅

@emdash-ie emdash-ie merged commit aca3366 into main Sep 2, 2024
1 check passed
@emdash-ie emdash-ie deleted the bt/fix-json-tests branch September 2, 2024 09:58
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants