Skip to content

Poor error reporting in cram tests #4230

@aalekseyev

Description

@aalekseyev

In cram tests, there are cases where dune blows up with a confusing error where it could have reported a better error.

Example 1 (sh syntax error):

Define a function with a dash in its name

  $ foo-bar () {
  >   true
  > }

There is no error message at all, even though sh reports an error correctly.

Dune:

          sh (internal) (exit 2)             
(cd _build/.sandbox/a76f004532a7d5adefdceb308f650161/default/test/blackbox-tests/test-cases/watching/test-1.t && /usr/bin/sh /tmp/dune.cram.bf2305run.t/main.sh)

Sh:

$ sh -c 'foo-bar () { true; }'
sh: `foo-bar': not a valid identifier
EXIT STATUS 2

Example 2 (script terminates early):

  $ true
  $ exit 0

Observed error:

Internal error, please report upstream including the contents of _build/log.
Description:
  ("command without metadata", {})
Raised at Stdune__Code_error.raise in file "src/stdune/code_error.ml", line
  9, characters 30-62
Called from Dune_rules__Cram_exec.run in file "src/dune_rules/cram_exec.ml",
  line 411, characters 12-48
... (many more useless stack frames) ...

Expected error: replacing all sections that weren't reached with a text explaining that this section was not reached.

Specifications

  • Version of dune: b9f0ad8 (2.7.1+)

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedaccepted proposalscramRelated to the cram test execution in Dune

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions