Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

[Feature request] Command line option to ignore tests failures when the exit code is computed #238

Open
NBardelot opened this issue Sep 26, 2017 · 2 comments

Comments

@NBardelot
Copy link

When one or more tests fail at the moment the bats command exits with an error code of 1. If there is a syntax error in the bats file, the behaviour is the same.

The feature would consist of a flag (for example "-i|--ignore-failures"), so that the exit code is 0 even if some tests fail, allowing the caller to differenciate between abnormal behaviour (exit code > 0) and tests failures (exit code = 0, but number of failures > 0 as printed in stdout).

@NBardelot
Copy link
Author

NBardelot commented Sep 26, 2017

Note:

For the moment in order to achieve the same goal I have to use the following wrapper script:

#!/bin/bash

clean_exit() {
    cat "$1"
    /bin/rm -f "$ERR_FILE" "$OUT_FILE"
    exit "$2"
}

OUT_FILE=$(mktemp)
ERR_FILE=$(mktemp)
bats $@ 1>"$OUT_FILE" 2>"$ERR_FILE"
RETVAL=$?
if [ $RETVAL -ne 0 ]
then
  if [ $(wc -l "$ERR_FILE" | awk '{ print $1 }') -gt 0 ]
  then
    clean_exit "$ERR_FILE" 1 # Abnormal error (probably a syntax error)!
  else
    clean_exit "$OUT_FILE" 2 # One or more tests fail
  fi
fi
clean_exit "$OUT_FILE" 0

@Potherca
Copy link

This project is no longer being actively maintained by its original auther (see #236).

You might want to migrate to the community maintained fork bats-core and report your issue there.

yarikoptic pushed a commit to neurodebian/bats that referenced this issue Aug 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants