Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ignore files and folders in bashcov in GitLab-CI yaml? #66

Closed
a-t-0 opened this issue Oct 19, 2022 · 1 comment
Closed

How to ignore files and folders in bashcov in GitLab-CI yaml? #66

a-t-0 opened this issue Oct 19, 2022 · 1 comment

Comments

@a-t-0
Copy link

a-t-0 commented Oct 19, 2022

Thank you for your work on this project! While trying to run Bashcov on a basic BATS testing repo in a .GitLab-CI.yml:

image: vergissberlin/alpine-development

stages:
  - build
  - deploy

test:
  stage: build
  image: ruby:slim
  before_script:
    - gem install bashcov
  script:
    # bashcov cannot run as root so here's a magic user
    - useradd -s /bin/bash user
    - su user -c "$(command -v bashcov) test"
  coverage: '/\(\d+\.\d+%\) covered/'
  artifacts:
    untracked: true

I receive the error:

bashcov: warning: encountered an error parsing Bash's output (error was: expected integer for LINENO, got ""). This can occur if your script or its path contains the sequence "010ae148-b419-4384-b227-69b97f25cdb6", or if your script unsets LINENO. Aborting early; coverage report will be incomplete.

So after scanning the tested repo I noticed the bats installation packages at: test/libs/bats/* contain the $lineno variable.

enter image description here

So I thought I would perhaps be able to circumvent this error by adding the test/libs/bats/* dir to the ignored folders when I run bashcov with:

bashcov bats test

However, after inspecting the documentation:

bashcov --help
Usage: bashcov [options] [--] <command> [options]
Examples:
    bashcov ./script.sh
    bashcov --skip-uncovered ./script.sh
    bashcov -- ./script.sh --some --flags
    bashcov --skip-uncovered -- ./script.sh --some --flags

Specific options:
    -s, --skip-uncovered             Do not report uncovered files
    -m, --mute                       Do not print script output
        --bash-path PATH             Path to Bash executable
        --root PATH                  Project root directory
        --command-name NAME          Value to use as SimpleCov.command_name

Common options:
    -h, --help                       Show this message
        --version                    Show version

I did not find an option to ignore certain folders. Hence, I would like to ask:

How can I specify ignored folders and files when running bashcov bats test?

@a-t-0
Copy link
Author

a-t-0 commented Dec 24, 2022

The --exclude/--ignore option is supported through a SimpleCov configuration file. In the root directory of one's own project, one can add a .simplecov file with content:

SimpleCov.start do
  minimum_coverage 15
  add_filter "test/libs"
  add_filter "/.git/"
end

And that ensures the coverage report and result ignore those test/libs/ and .git/ directories.

@a-t-0 a-t-0 closed this as completed Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant