Skip to content

Included script with a relative path are not covered #327

@beatussum

Description

@beatussum

Description

If a specfile include (Include) a file foo with a relative path and the directory from where shellspec is called differs from the one specified by --execdir, foo is not covered with --kcov.

In details

Consider the following lines:

  (
    "$SHELLSPEC_KCOV_PATH" \
    $SHELLSPEC_KCOV_COMMON_OPTS \
    $SHELLSPEC_KCOV_OPTS \
    --bash-method=DEBUG \
    --bash-parser="$SHELLSPEC_SHELL" \
    --bash-parse-files-in-dir=. \
    --configure=command-name="shellspec $*" \
    "$SHELLSPEC_COVERAGEDIR" "$SHELLSPEC_KCOV_IN_FILE"
  ) 8>&1

kcov is executed inside "${PWD}" and relative paths are computed from ${PWD}; however, relative paths specified with Include are relative to "${SHELLSPEC_EXECDIR}".

In this way,

  1. when kcov get the filename from the different traps loaded from here, the second field ${BASH_SOURCE[0]:-} has a relative path computed from "${SHELLSPEC_EXECDIR}",
  2. kcov tries to get the associated absolute path (here),
  3. realpath() (called here) returns null and filename is the relative path as it was before,
  4. it fails here.

Solution?

I don't have a good overall view of the project and it's very likely that I'm talking nonsense. I apologize in advance if this is the case.

Hardcoded the right cd in the subshell for a small example was successful, therefore I think that a shellspec_execdir "${SHELLSPEC_EXECDIR}" should be called here or before this subshell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions