Commit a68b3483 authored by Dominique Barton's avatar Dominique Barton 🦄
Browse files

TEST: Fix testing by using diff

parent 30e574c7
Pipeline #13294 passed with stage
in 1 minute
......@@ -25,21 +25,21 @@ install: install-python install-node
#
test-isort:
./validateOutput.sh "isort --sp ../configs/isort.cfg -c files/test.py" output/isort.txt
./test-command "isort --sp ../configs/isort.cfg -c test-files/test.py" expected-output/isort.txt
test-pycodestyle:
./validateOutput.sh "pycodestyle --config=../configs/tox.ini files/test.py" output/pycodestyle.txt
./test-command "pycodestyle --config=../configs/tox.ini test-files/test.py" expected-output/pycodestyle.txt
test-pylint:
./validateOutput.sh "pylint --rcfile=../configs/pylintrc --score=n files/test.py" output/pylint.txt
./test-command "pylint --rcfile=../configs/pylintrc --score=n test-files/test.py" expected-output/pylint.txt
test-coverage:
./validateOutput.sh "coverage run --rcfile=../configs/coveragerc files/test.py" output/coverage.txt
./test-command "coverage run --rcfile=../configs/coveragerc test-files/test.py" expected-output/coverage.txt
test-eslint:
./validateOutput.sh "npx --silent eslint -c ../configs/eslintrc.yml files/test.js" output/eslint.txt
./test-command "npx --silent eslint -c ../configs/eslintrc.yml test-files/test.js" expected-output/eslint.txt
test-stylelint:
./validateOutput.sh "npx --silent stylelint --config ../configs/stylelintrc.yml files/test.css" output/stylelint.txt
./test-command "npx --silent stylelint --no-color --config ../configs/stylelintrc.yml test-files/test.css" expected-output/stylelint.txt
test: test-isort test-pycodestyle test-pylint test-coverage test-eslint
{PWD}/files/test.js
{PWD}/test-files/test.js
1:1 error Identifier 'invalid_name' is not in camel case camelcase
1:1 error 'invalid_name' is not defined no-undef
......
ERROR: {PWD}/test-files/test.py Imports are incorrectly sorted and/or formatted.
test-files/test.py:9:1: W391 blank line at end of file
************* Module test
test-files/test.py:9:0: C0305: Trailing newlines (trailing-newlines)
test-files/test.py:8:0: C0103: Constant name "invalid_name" doesn't conform to UPPER_CASE naming style (invalid-name)
test-files/test.py:5:0: W0611: Unused import sys (unused-import)
test-files/test.py:6:0: W0611: Unused import os (unused-import)
files/test.css
3:23 ✖ Expected "#000" to be "#000000" color-hex-length
4:23 ✖ Unexpected named color "black" color-named
7:1 ✖ Unexpected duplicate selector "body", first used at line 1 no-duplicate-selectors
11:1 ✖ Unexpected unknown type selector "foo" selector-type-no-unknown
13:5 ✖ Unexpected empty line before declaration declaration-empty-line-before
test-files/test.css
3:23 ✖ Expected "#000" to be "#000000" color-hex-length
4:23 ✖ Unexpected named color "black" color-named
7:1 ✖ Unexpected duplicate selector "body", first used at line 1 no-duplicate-selectors
11:1 ✖ Unexpected unknown type selector "foo" selector-type-no-unknown
13:5 ✖ Unexpected empty line before declaration declaration-empty-line-before
19:1 ✖ Unexpected empty line before closing brace block-closing-brace-empty-line-before
ERROR: {PWD}/files/test.py Imports are incorrectly sorted and/or formatted.
files/test.py:9:1: W391 blank line at end of file
************* Module test
files/test.py:9:0: C0305: Trailing newlines (trailing-newlines)
files/test.py:8:0: C0103: Constant name "invalid_name" doesn't conform to UPPER_CASE naming style (invalid-name)
files/test.py:5:0: W0611: Unused import sys (unused-import)
files/test.py:6:0: W0611: Unused import os (unused-import)
#!/bin/bash
# Create temporary files.
GIVEN=$(mktemp /tmp/$(basename $0).XXXX)
EXPECTED=$(mktemp /tmp/$(basename $0).XXXX)
# Cleanup temporary files on exit.
trap 'rm -f ${GIVEN} ${EXPECTED}' EXIT
# Write given output and expected output to temporary files.
${1} >${GIVEN} 2>&1
cat ${2} | sed "s|{PWD}|$(pwd)|g" >${EXPECTED}
# Compare given and expected output.
echo "> ${1}"
diff -ubB ${GIVEN} ${EXPECTED} || exit
echo
#!/bin/bash
echo "--------------------------------------------------------------------------------"
echo "Command:"
echo ${1}
GIVEN=$(${1} 2>&1)
echo
echo "Given:"
echo "${GIVEN}"
echo
echo "Expected:"
EXPECTED=$(cat ${2})
EXPECTED=${EXPECTED//\{PWD\}/$(pwd)}
echo "${EXPECTED}"
echo
if [[ "${GIVEN}" == "${EXPECTED}" ]]
then
echo "==> VALIDATION SUCCESSFUL!"
EXIT_CODE=0
else
echo "==> VALIDATION FAILED!"
EXIT_CODE=1
fi
echo "--------------------------------------------------------------------------------"
exit ${EXIT_CODE}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment