Skip to content

The bootstrap error says 'cannot read' for three different causes #1262

Description

@Chemaclass

Problem

-e/--env/--boot reports the same message whatever went wrong:

$ bashunit --env somedir t_test.sh     # a directory
Error: cannot read the bootstrap file: 'somedir'.

$ bashunit --env unread.sh t_test.sh   # exists, mode 000
Error: cannot read the bootstrap file: 'unread.sh'.

$ bashunit --env nope.sh t_test.sh     # does not exist
Error: cannot read the bootstrap file: 'nope.sh'.

It is accurate for exactly one of them. A directory is readable — the check that rejects it is -f, not -r — and for a path that does not exist, "cannot read" understates "is not there". Pointing --env at a directory (--env tests/, --boot config/) or mistyping a filename are both ordinary mistakes, and the message sends the reader to permissions in either case.

/dev/null is rejected the same way, which is how I noticed: it is readable and the message says otherwise.

Fix

Name the actual cause, the way install.sh does for its destination since #1197:

  • does not exist → say so
  • is a directory → say so (bashunit::main::report_path_is_a_directory already exists in the same file for this)
  • exists but unreadable → the current message, now true

The --env space-split explanation added in #1247 stays as-is on top.

Related

Same class as #1197 (install destinations), #1221 (advice naming a flag that does not exist) and #1247 (the split that made a real file look missing).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions