Skip to content

Error parsing if/else block in test-suite stanza of cabal file #6530

@nghamilton

Description

@nghamilton

Using an if/else block to provide alternative main-is values in the test-suite stanza results in a parsing error:

Test suite "cabal-bug" is missing required field "type" or the field is not present in all conditional branches.

Minimal reproducible example.

A workaround is to include type field in both branches, as suggested by the error message:

  if flag(breaks)
    main-is:         Main1.hs
    type:            exitcode-stdio-1.0
  else
    main-is:         Main2.hs
    type:            exitcode-stdio-1.0

If this is the expected behavior, the error message could possibly be expressed more clearly, or the documentation could state the type field should be present in all conditional branches.

Tested on cabal version 3.0.0.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions