stefan2904 / shunit2

Automatically exported from code.google.com/p/shunit2
0 stars 0 forks source link

assertEquals repeats message argument #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Run the following shell script:
#!/bin/ksh
test_shunit2() {
        assertEquals "My message." 1 2
}
. ./shunit2

What is the expected output?
#
# Performing tests
#
test_shunit2
ASSERT:My message. expected:<1> but was:<2>

#
# Test report
#
tests passed:     0   0%
tests failed:     1 100%
tests skipped:    0   0%
tests total:      1 100%

What do you see instead?
#
# Performing tests
#
test_shunit2
ASSERT:My message.My message. expected:<1> but was:<2>

#
# Test report
#
tests passed:     0   0%
tests failed:     1 100%
tests skipped:    0   0%
tests total:      1 100%

What version of the product are you using?
shUnit 2.1.4

On what operating system?
AIX (IBM Unix)

Using Korn Shell

Original issue reported on code.google.com by malcolm....@gmail.com on 17 Sep 2008 at 3:36

GoogleCodeExporter commented 9 years ago
I recently noticed this too. Here's a patch with a single unit test added. (More
however would not be a bad idea.)

In addition to the above noted fix there are two other small changes.

Also "make test" in the source was not working because in this line
test: @echo
there should be a line break. And while I was in that section I added a "check"
target as sort of an alias for "test". (GNU automake uses "make check" instead 
of
"make test".

Original comment by rocky.bernstein on 27 Sep 2008 at 9:54

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Rocky,

I'm not sure what I need to do with assert-output.diff

I tried:

patch shunit2 < assert-output.diff

but got:

Processing...  I cannot find a patch in there anywhere.

Is there another patch-like utility I should be using? Do I need to split up
the file assert-output.diff and patch using just one part of it?

Regards, Mal.

Original comment by malcolm....@gmail.com on 3 Oct 2008 at 4:34

GoogleCodeExporter commented 9 years ago
Works for me 
$  cd ...shunit2/trunk/source/2.1
$  patch -p0 < ~/Desktop/assert-output.diff 
patching file src/shell/shunit2.
...

$ patch --version
patch 2.5.9
Copyright (C) 1988 Larry Wall
Copyright (C) 2003 Free Software Foundation, Inc.

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

If this is not the version of that your are using get it from
ftp://ftp.gnu.org:/pub/gnu/patch/patch-2.5.4.tar.gz

If you can't do that, edit the file:

--- src/shell/shunit2   (revision 226)
+++ src/shell/shunit2   (working copy)
@@ -124,7 +124,7 @@

   [ -z "${shunit_message_:-}" ] && shunit_message_=''
   if [ $# -eq 3 ]; then
-    shunit_message_="${shunit_message_}$1"
+    shunit_message_="$1"
     shift
   fi
   shunit_expected_=$1

And look for a line like the one that has - in it and change it to a
line like the one that has + in it.

Good luck.

Original comment by rocky.bernstein on 3 Oct 2008 at 7:15

GoogleCodeExporter commented 9 years ago
The provided patch is only a hack to fix a larger problem, one that stems from 
the _SHUNIT_LINENO_ macro. I'm 
looking into it.

Original comment by kate.a.w...@gmail.com on 7 Oct 2008 at 10:25

GoogleCodeExporter commented 9 years ago
Ah, actually it stems from the fact that when assertEquals fails, it calls 
failNotEqual, which itself extends the 
shunit_message_ variable yet again with the same information. Now, how to fix...

Original comment by kate.a.w...@gmail.com on 7 Oct 2008 at 10:44

GoogleCodeExporter commented 9 years ago
Fixed in rev# 230.

Original comment by kate.a.w...@gmail.com on 7 Oct 2008 at 11:16