Skip to content

cabal init bootstraps a test suite *only* by default when interactive is set to False in the global configuration #11377

@Kleidukos

Description

@Kleidukos

Actual behaviour

Here is the output from a simple cabal init in my terminal:

hecate@ifrit ~/gperf-example ❯ cabal init
Package name? [default: gperf-example] 
Package version? [default: 0.1.0.0] 
Author name? 
Maintainer email? 
Project homepage URL? [optional] 
Project synopsis? [optional] 
Project category:
   1) Codec
   2) Concurrency
   3) Control
   4) Data
   5) Database
   6) Development
   7) Distribution
   8) Game
   9) Graphics
  10) Language
  11) Math
  12) Network
  13) Sound
  14) System
  15) Testing
  16) Text
  17) Web
  18) Other (specify)
Your choice? [default: (none)] 18
Please specify? [optional] 
What is the main module of the test suite?:
 * 1) Main.hs
   2) Main.lhs
   3) Other (specify)
Your choice? [default: Main.hs] 
Add informative comments to each field in the cabal file. (y/n)? [default: y] n
[Info] Using cabal specification: 3.6
[Info] Creating fresh file LICENSE...
[Info] Creating fresh file CHANGELOG.md...
[Info] Creating fresh directory ./test...
[Info] Creating fresh file test/Main.hs...
[Info] Creating fresh file gperf-example.cabal...
[Warn] No synopsis given. You should edit the .cabal file and add one.
[Info] You may want to edit the .cabal file and add a Description field.

This only gives me a test suite with the cabal file. I tried on another machine which gave me the option for the build target, and it would appear that setting interactive to False in the global configuration sets Test suite by default, whereas "Executable" is offered by default in the interactive menu.

My configuration block for cmd/init was as follows:

init                  
  -- interactive: False   
  cabal-version: 3.6  
  license: MIT        
  tests: True         
  test-dir: test      
  language: GHC2021   
  application-dir: app
  source-dir: src     

None of these options advertise that their combination will only produce a test suite and not an executable or a library.

Expected behaviour

As an end-user I expect the interactive and non-interactive menus to be consistent. Moreover, generating a test suite by default is useless and amounts for too niche of a use case for it to be set as the non-interactive default.

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