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

Improve assertion messages in IntegrationTests2 testConfigOptionComments #10314

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

9999years
Copy link
Collaborator

Before, failing asserts in this test would look like this:

Writing default configuration to
/Users/wiggles/cabal/cabal-install/tests/IntegrationTests2/config/cabal-config/config
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org has been updated.
The index-state is set to 2024-09-04T15:12:07Z.
Integration tests (internal)
  Flag tests
    Test Config options for commented options: FAIL
      tests/IntegrationTests2.hs:2015:
      expected: "  urll"
       but got: "  url"

The output includes a message that a configuration file has been written, but that's not the configuration file under test! The actual configuration file being tested is
cabal-install/tests/IntegrationTests2/config/default-config, which shows up nowhere in the output.

Now, the messages include the setting name being searched for and the path of the relevant configuration file:

Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org has been updated.
The index-state is set to 2024-09-04T22:53:05Z.
Integration tests (internal)
  Flag tests
    Test Config options for commented options: FAIL
      tests/IntegrationTests2.hs:2015:
      Did not find expected line for setting "url" in configuration file /Users/wiggles/cabal/cabal-install/tests/IntegrationTests2/config/default-config
      expected: "  urll"
       but got: "  url"

The Writing default configuration to... message with the misleading path has also been silenced.

Before, failing asserts in this test would look like this:

```
Writing default configuration to
/Users/wiggles/cabal/cabal-install/tests/IntegrationTests2/config/cabal-config/config
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org has been updated.
The index-state is set to 2024-09-04T15:12:07Z.
Integration tests (internal)
  Flag tests
    Test Config options for commented options: FAIL
      tests/IntegrationTests2.hs:2015:
      expected: "  urll"
       but got: "  url"
```

The output includes a message that a configuration file has been
written, but that's not the configuration file under test! The actual
configuration file being tested is
`cabal-install/tests/IntegrationTests2/config/default-config`, which
shows up nowhere in the output.

Now, the messages include the setting name being searched for and the
path of the relevant configuration file:

```
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org has been updated.
The index-state is set to 2024-09-04T22:53:05Z.
Integration tests (internal)
  Flag tests
    Test Config options for commented options: FAIL
      tests/IntegrationTests2.hs:2015:
      Did not find expected line for setting "url" in configuration file /Users/wiggles/cabal/cabal-install/tests/IntegrationTests2/config/default-config
      expected: "  urll"
       but got: "  url"
```

The `Writing default configuration to...` message with the misleading
path has also been silenced.
callProcess "cabal" ["user-config", "init", "-f"]
-- NOTE: This is running the `cabal` from the user environment, which is
-- generally not the `cabal` being tested!
callProcess "cabal" ["-v0", "user-config", "init", "-f"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

That one was my fault; I'd intended to silence it after verifying it, but forgot. (See #10205.)

The choice to use the environment cabal was deliberate, as I wanted a reliable pristine configuration for the tests and it seemed to me that using the cabal under test was incorrect, especially since that is only tested much later.

@9999years 9999years added the merge me Tell Mergify Bot to merge label Sep 5, 2024
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.

2 participants