Skip to content

Using coverage/coverageOff preserves settings overrides #175

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

Conversation

mtrampont
Copy link

Hi,

This PR addresses the issue #146 .
The problem was that the method Extracted.append actually drops the settings that were added with the set command.
You can see it here: https://github.com/sbt/sbt/blob/1.0.x/main/src/main/scala/sbt/Extracted.scala#L105
session.original is used instead of session.mergeSettings .

Instead of using Extracted.append I used SessionSettings.reapply.

I added a scripted test to check that coverage and coverageOff do not reset settings set with set.

When running the scripted tests, aggregate was failing because a call to coverageReport was missing (according to https://github.com/scoverage/sbt-scoverage#multi-project-reports).
Also, coverage-off is failing because of 0f9496d , but it should be fixed by PR #166 or PR #168.

@gslowikowski
Copy link
Member

@mtrampont can you rebase and update this PR?

toggleCoverage method, after merge, should now look like:

  private def toggleCoverage(status: Boolean): State => State = { state =>
    val extracted = Project.extract(state)
    val currentProjRef = extracted.currentRef
    val newSettings = extracted.structure.allProjectRefs.flatMap(proj =>
      Seq(coverageEnabled in proj := status)
    )
    val appendSettings = Load.transformSettings(Load.projectScope(currentProjRef), currentProjRef.build, extracted.rootProject, newSettings)
    val newSessionSettings = extracted.session.appendRaw(appendSettings)
    SessionSettings.reapply(newSessionSettings, state)
  }

@gslowikowski
Copy link
Member

Closed by #186

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