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

Added color code to the result (green, red & yellow) #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dacacioa
Copy link

@dacacioa dacacioa commented Apr 1, 2015

Added color code to the result to easy check:

Ok -> Green
Failed -> Red
Assert Failure -> Yellow

@alex-harvey-z3q
Copy link

+1

@alex-harvey-z3q
Copy link

Actually, this patch breaks the project's own shUnit2 tests, e.g.

e.g.

$ bash shunit2_test_macros.sh 
testAssertEquals
\e[93mASSERT:_ASSERT_EQUALS_ failure\e[0m
\e[93mASSERT:_ASSERT_EQUALS_ w/ msg failure\e[0m
testAssertNotEquals
\e[93mASSERT:_ASSERT_NOT_EQUALS_ failure\e[0m
\e[93mASSERT:_ASSERT_NOT_EQUALS_ w/ msg failure\e[0m
testSame
\e[93mASSERT:_ASSERT_SAME_ failure\e[0m
\e[93mASSERT:_ASSERT_SAME_ w/ msg failure\e[0m
testNotSame
\e[93mASSERT:_ASSERT_NOT_SAME_ failure\e[0m
\e[93mASSERT:_ASSERT_NOT_SAME_ w/ msg failure\e[0m
testNull
\e[93mASSERT:_ASSERT_NULL_ failure\e[0m
\e[93mASSERT:_ASSERT_NULL_ w/ msg failure\e[0m
testNotNull
\e[93mASSERT:_ASSERT_NOT_NULL_ failure\e[0m
\e[93mASSERT:_ASSERT_NOT_NULL_ w/ msg failure\e[0m
\e[93mASSERT:[119] some msg\e[0m
testAssertTrue
\e[93mASSERT:_ASSERT_TRUE_ failure\e[0m
\e[93mASSERT:_ASSERT_TRUE_ w/ msg failure\e[0m
testAssertFalse
\e[93mASSERT:_ASSERT_FALSE_ failure\e[0m
\e[93mASSERT:_ASSERT_FALSE_ w/ msg failure\e[0m
testFail
\e[93mASSERT:_FAIL_ failure\e[0m
\e[93mASSERT:_FAIL_ w/ msg failure\e[0m
testFailNotEquals
\e[93mASSERT:_FAIL_NOT_EQUALS_ failure\e[0m
\e[93mASSERT:_FAIL_NOT_EQUALS_ w/ msg failure\e[0m
testFailSame
\e[93mASSERT:_FAIL_SAME_ failure\e[0m
\e[93mASSERT:_FAIL_SAME_ w/ msg failure\e[0m
testFailNotSame
\e[93mASSERT:_FAIL_NOT_SAME_ failure\e[0m
\e[93mASSERT:_FAIL_NOT_SAME_ w/ msg failure\e[0m

Ran 12 tests.

\e[31mFAILED (failures=24)\e[0m

@dacacioa
Copy link
Author

dacacioa commented Jul 6, 2017

I fixed the code to pass all the tests. I have pending to implement the yellow color to Assert Failure.

#------------------------------------------------------------------------------
# Running the test suite with /bin/sh
#
shell name: sh
shell version: unknown

--- Executing the 'asserts' test suite ---
testAssertEquals
testAssertNotEquals
testAssertSame
testAssertNotSame
testAssertNull
testAssertNotNull
testAssertTrue
testAssertFalse

Ran 8 tests.


OK


--- Executing the 'failures' test suite ---
testFail
testFailNotEquals
testFailSame

Ran 3 tests.


OK


--- Executing the 'macros' test suite ---
testAssertEquals
testAssertNotEquals
testSame
testNotSame
testNull
testNotNull
testAssertTrue
testAssertFalse
testFail
testFailNotEquals
testFailSame
testFailNotSame

Ran 12 tests.


OK


--- Executing the 'misc' test suite ---
testUnboundVariable
testIssue7
testPrepForSourcing
testEscapeCharInStr
testEscapeCharInStr_specialChars
testExtractTestFunctions

Ran 6 tests.


OK


--- Executing the 'standalone' test suite ---
testStandalone

Ran 1 test.


OK



#------------------------------------------------------------------------------
# Running the test suite with /bin/bash
#
shell name: bash
shell version: GNU bash, versión 4.1.2(2)-release (x86_64-redhat-linux-gnu)

--- Executing the 'asserts' test suite ---
testAssertEquals
testAssertNotEquals
testAssertSame
testAssertNotSame
testAssertNull
testAssertNotNull
testAssertTrue
testAssertFalse

Ran 8 tests.


OK


--- Executing the 'failures' test suite ---
testFail
testFailNotEquals
testFailSame

Ran 3 tests.


OK


--- Executing the 'macros' test suite ---
testAssertEquals
testAssertNotEquals
testSame
testNotSame
testNull
testNotNull
testAssertTrue
testAssertFalse
testFail
testFailNotEquals
testFailSame
testFailNotSame

Ran 12 tests.


OK


--- Executing the 'misc' test suite ---
testUnboundVariable
testIssue7
testPrepForSourcing
testEscapeCharInStr
testEscapeCharInStr_specialChars
testExtractTestFunctions

Ran 6 tests.


OK


--- Executing the 'standalone' test suite ---
testStandalone

Ran 1 test.


OK

@alex-harvey-z3q
Copy link

@dacacioa Oh that's fantastic. I really want this feature. I was going to take this patch and try to get it merged upstream in the real shUnit2 https://github.com/kward/shunit2 -- happy to do that, or maybe you would like to do it yourself. I think you would have to rebase since the project moved on a bit after zandev's fork.

@dacacioa
Copy link
Author

@alexharv074 done!

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

Successfully merging this pull request may close these issues.

2 participants