Skip to content

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

Merged
mergify[bot] merged 6 commits into
haskell:masterfrom
jneira:no-dup-global-cfg
Oct 18, 2021
Merged

mergify[bot] merged 6 commits into
haskell:masterfrom
jneira:no-dup-global-cfg

Conversation

@jneira

@jneira jneira commented Oct 15, 2021 •

Copy link
Copy Markdown
Member

@jneira
jneira requested review from gbaz and phadej 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

jneira commented Oct 15, 2021

Copy link
Copy Markdown
Member Author

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

@jneira

jneira commented Oct 15, 2021

Copy link
Copy Markdown
Member Author

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

jneira commented Oct 15, 2021 •

Copy link
Copy Markdown
Member Author

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

Mikolaj commented Oct 15, 2021

Copy link
Copy Markdown
Member

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

@mouse07410

Copy link
Copy Markdown
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

jneira commented Oct 15, 2021

Copy link
Copy Markdown
Member Author

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

jneira commented Oct 18, 2021

Copy link
Copy Markdown
Member Author

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

jneira commented Oct 18, 2021

Copy link
Copy Markdown
Member Author

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

jneira commented Oct 18, 2021

Copy link
Copy Markdown
Member Author

Demoting to draft until #7759 is merged in master

@jneira

jneira commented Oct 18, 2021

Copy link
Copy Markdown
Member Author

@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
@jneira
jneira force-pushed the no-dup-global-cfg branch from b3ebb00 to c2c394b Compare October 18, 2021 15:42
@mergify

mergify Bot commented Oct 18, 2021

Copy link
Copy Markdown
Contributor

rebase master

✅ Branch has been successfully rebased

@jneira

jneira commented Oct 18, 2021

Copy link
Copy Markdown
Member Author

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

@Mikolaj Mikolaj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well spotted. LGTM.

@jneira

jneira commented Oct 18, 2021

Copy link
Copy Markdown
Member Author

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

Mikolaj commented Oct 18, 2021

Copy link
Copy Markdown
Member
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

Mikolaj commented Oct 18, 2021

Copy link
Copy Markdown
Member

Perhaps expectBroken changes output? That would be sad.

@jneira

jneira commented Oct 18, 2021 •

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

Using cabal install in a project or install/repl without a project, duplicates global config and rebuilds libs twice in the store

4 participants