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

Avoid using duplicate global config not adding it in the dummy project context #7753

Merged
merged 6 commits into from
Oct 18, 2021

Conversation

jneira
Copy link
Member

@jneira jneira commented Oct 15, 2021

@jneira jneira requested review from phadej and gbaz October 15, 2021 10:05
@jneira jneira changed the title Not add global config in the dummy project context Don't add global config in the dummy project context Oct 15, 2021
@jneira jneira marked this pull request as draft October 15, 2021 10:13
@jneira
Copy link
Member Author

jneira commented Oct 15, 2021

The pr still misses the repl and run actions in a project context cases

@jneira
Copy link
Member Author

jneira commented Oct 15, 2021

The pr still misses the repl and run actions in a project context cases

It is already covered indeed cause establishDummyProjectBaseContext is called inside the without project code branch

@jneira jneira marked this pull request as ready for review October 15, 2021 10:23
@jneira jneira force-pushed the no-dup-global-cfg branch 2 times, most recently from 1b51846 to 1d5f322 Compare October 15, 2021 10:32
@jneira
Copy link
Member Author

jneira commented Oct 15, 2021

Trying to discover tests, i did not find:

  • any occurrence of withProjectOrGlobalConfig, establishDummyProjectBaseContext, replAction, runAction, installAction nor the correlated *Command functions outside prod code so i assume there is no unit tests for any of them
  • any occurrence of hash.txt outside prod code, so i assume there is no integration tests checking it
  • any tests checking the contents of the store (without an exhaustive search tbh)

So one path of action i can think of could be add the output of hash.txt in the cabal output with v3 (in another pr?) and check for the correct extra-*-dirs value setting it in the global config

@Mikolaj
Copy link
Member

Mikolaj commented Oct 15, 2021

Yes, the test suite has surprising gaps, in particular, not testing some of its own machinery. ;)

@mouse07410
Copy link
Collaborator

I'm confused by the title of this PR.

I thought the "final" project context should be:

  • global context taken from ~/.cabal/config, then
  • local context from {<project>.cabal plus cabal.project plus cabal.project.local} that overrides, modifies, and complements the global context.

Is that what your PR enforces? If not, I'd love to see an explanation.

@jneira
Copy link
Member Author

jneira commented Oct 15, 2021

well the problem is the global config was being added twice, hence the duplication of some config options
so the pr removes the inclusion of global config in one call site (establishDummyProjectBaseContext), after checking all client code is already including such config before calling it

will try to rephrase the title to make it clearer

@jneira jneira mentioned this pull request Oct 18, 2021
@jneira jneira changed the title Don't add global config in the dummy project context Avoid duplicate global config not adding it in the dummy project context Oct 18, 2021
@jneira
Copy link
Member Author

jneira commented Oct 18, 2021

Tests:

* From a functional pov afaik the unique observable change is the bad input in hash.txt.. Not sure if it is already being examined in other tests

* Would love to have some help about how and where to add unit tests

Regression tests added in #7759, will rebase this after being merged

@jneira
Copy link
Member Author

jneira commented Oct 18, 2021

I have to thanks @vituscze their analysis of the bug here, which has made lot easier this fix

@jneira jneira changed the title Avoid duplicate global config not adding it in the dummy project context Avoid using duplicate global config not adding it in the dummy project context Oct 18, 2021
@jneira jneira marked this pull request as draft October 18, 2021 12:16
@jneira
Copy link
Member Author

jneira commented Oct 18, 2021

Demoting to draft until #7759 is merged in master

@jneira
Copy link
Member Author

jneira commented Oct 18, 2021

@Mergifyio rebase master

* Afaics all establishDummyProjectBaseContext uses in the codebase
(CmdInstall, CmdRepl and CmdRun) are guarded by
ProjectOrchestation.withProjectOrGlobalConfig and it is already
adding the global config
* Changed the argament name from cliConfig to projectConfig to make
clear it includes the config from more sources than the cli.
* Added an argument comment to make clear client code *must* include
the global config if it is needed
@mergify
Copy link
Contributor

mergify bot commented Oct 18, 2021

rebase master

✅ Branch has been successfully rebased

@jneira
Copy link
Member Author

jneira commented Oct 18, 2021

test has failed successfully ☺️

PackageTests/Regression/T6906/cabal.test.hs FAIL (unexpected success) (2.36s)

@jneira jneira marked this pull request as ready for review October 18, 2021 16:31
@jneira jneira requested a review from Mikolaj October 18, 2021 16:32
Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

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

Well spotted. LGTM.

@jneira
Copy link
Member Author

jneira commented Oct 18, 2021

ci has failed quite misteriously:

Actual output differs from expected:

stderr:
--- /Users/runner/work/cabal/cabal/cabal-testsuite/PackageTests/Regression/T6906/cabal.dist/cabal.out.normalized	2021-10-18 17:33:18.000000000 +0000
+++ /Users/runner/work/cabal/cabal/cabal-testsuite/PackageTests/Regression/T6906/cabal.dist/cabal.comp.out.normalized	2021-10-18 17:33:18.000000000 +0000
@@ -0,0 +1 @@

🤔

@Mikolaj
Copy link
Member

Mikolaj commented Oct 18, 2021

cabal-testsuite/src/Test/Cabal/Monad.hs--- | The file where the expected output of the test lives
cabal-testsuite/src/Test/Cabal/Monad.hs-testExpectFile :: TestEnv -> FilePath
cabal-testsuite/src/Test/Cabal/Monad.hs-testExpectFile env = testSourceDir env </> testName env <.> "out"
cabal-testsuite/src/Test/Cabal/Monad.hs-
cabal-testsuite/src/Test/Cabal/Monad.hs--- | Where we store the actual output
cabal-testsuite/src/Test/Cabal/Monad.hs-testActualFile :: TestEnv -> FilePath
cabal-testsuite/src/Test/Cabal/Monad.hs:testActualFile env = testWorkDir env </> testName env <.> "comp.out"

Not sure what that means.

@Mikolaj
Copy link
Member

Mikolaj commented Oct 18, 2021

Perhaps expectBroken changes output? That would be sad.

@jneira
Copy link
Member Author

jneira commented Oct 18, 2021

Tests has worked locally with b1f7bbe, adding recordMode DoNotRecord

recordMode :: RecordMode -> TestM a -> TestM a
recordMode mode = withReaderT (\env -> env {
testRecordUserMode = Just mode
})

I am still gazing at the code trying to understand why

@jneira jneira added merge me Tell Mergify Bot to merge and removed attention: needs-review labels Oct 18, 2021
@mergify mergify bot merged commit 8d959d0 into haskell:master Oct 18, 2021
@mouse07410
Copy link
Collaborator

Great! So, this one is merged.

Could you tell me when can I expect to see it in a released cabal-install?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Tell Mergify Bot to merge
Projects
None yet
4 participants