test::unit caller stack feature request

Discussion in 'Ruby' started by Simon Strandgaard, Feb 2, 2004.

  1. A typical call stack of mine look like the following.
    The last 10 lines is visual noise. Is it possible to get
    rid of these lines?

    --
    Simon Strandgaard

    1) Failure:
    test_repeat_nested14(TestMScanner)
    [./common.rb:64:in `assert_regex'
    ./match_mixins.rb:548:in `_debug_test_repeat_nested14'
    (eval):5:in `test_repeat_nested14']:
    <["abababab", "ab"]> expected but was
    <#<RuntimeError: integrity: expected "a . b", got "a b a b a b a b" at line 4> /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:520:in `check_integrit
    y'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:527:in `path_end'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:577:in `visit_last'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/scanner_nodes.rb:183:in `accept'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:630:in `find_match_at'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:639:in `match_impl'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:647:in `match'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:669:in `match_integrity'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:669:in `call'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:657:in `check_integrity'
    /home/neoneye/kode/editor/projects/regexp_engine/regexp/mscanner.rb:669:in `match_integrity'
    ../common.rb:38:in `match_integrity'
    ../common.rb:55:in `assert_regex'
    ../match_mixins.rb:548:in `_debug_test_repeat_nested14'
    (eval):5:in `test_repeat_nested14'
    /home/neoneye/stow/ruby/lib/ruby/1.8/test/unit/testcase.rb:70:in `__send__'
    /home/neoneye/stow/ruby/lib/ruby/1.8/test/unit/testcase.rb:70:in `run'
    /home/neoneye/stow/ruby/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
    /home/neoneye/stow/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
    /home/neoneye/stow/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
    /home/neoneye/stow/ruby/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite'
    /home/neoneye/stow/ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:72:in `start_mediator'
    /home/neoneye/stow/ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:46:in `start'
    /home/neoneye/stow/ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:21:in `run'
    test_mscanner.rb:93>.
    Simon Strandgaard, Feb 2, 2004
    #1
    1. Advertising

  2. On Feb 2, 2004, at 08:04, Simon Strandgaard wrote:

    > A typical call stack of mine look like the following.
    > The last 10 lines is visual noise. Is it possible to get
    > rid of these lines?


    Test::Unit _is_ stripping the stack that it has control over:

    > 1) Failure:
    > test_repeat_nested14(TestMScanner)
    > [./common.rb:64:in `assert_regex'
    > ./match_mixins.rb:548:in `_debug_test_repeat_nested14'
    > (eval):5:in `test_repeat_nested14']:


    Note that there is only a three line stack here. The noise below is
    somehow being caused by your use of Test::Unit. Why is...

    > <["abababab", "ab"]> expected but was


    ...an array being compared to...

    > <#<RuntimeError: integrity: expected "a . b", got "a b a b a b a b" at
    > line 4> /home/


    ... a RuntimeError? Without seeing at least the structure of your code,
    I can't figure out what's going on, but I don't think it's a Test::Unit
    issue. I can only make it so smart :)

    HTH,


    Nathaniel

    <:((><
    Nathaniel Talbott, Feb 2, 2004
    #2
    1. Advertising

  3. On Tue, 03 Feb 2004 00:09:16 +0900, Nathaniel Talbott wrote:

    > On Feb 2, 2004, at 08:04, Simon Strandgaard wrote:
    >
    >> A typical call stack of mine look like the following.
    >> The last 10 lines is visual noise. Is it possible to get
    >> rid of these lines?

    >
    > Test::Unit _is_ stripping the stack that it has control over:
    >
    >> 1) Failure:
    >> test_repeat_nested14(TestMScanner)
    >> [./common.rb:64:in `assert_regex'
    >> ./match_mixins.rb:548:in `_debug_test_repeat_nested14'
    >> (eval):5:in `test_repeat_nested14']:

    >
    > Note that there is only a three line stack here.


    Ok. I just never have noticed these lines until now. Earlier I have
    looked at the _really_ long stack dump.


    > The noise below is
    > somehow being caused by your use of Test::Unit. Why is...
    >
    >> <["abababab", "ab"]> expected but was

    >
    > ..an array being compared to...
    >
    >> <#<RuntimeError: integrity: expected "a . b", got "a b a b a b a b" at
    >> line 4> /home/

    >
    > .. a RuntimeError? Without seeing at least the structure of your code,
    > I can't figure out what's going on, but I don't think it's a Test::Unit
    > issue. I can only make it so smart :)


    Don't understand.


    The way I use test::unit is..

    require 'test/unit'
    class TestMScanner < Test::Unit::TestCase
    def test_me
    end
    end
    if $0 == __FILE__
    require 'test/unit/ui/console/testrunner'
    Test::Unit::UI::Console::TestRunner.run(TestMScanner, 3)
    end

    When I execute it, it results in the _long_ stack dump.
    Is it wrong? :)

    --
    Simon Strandgaard
    Simon Strandgaard, Feb 2, 2004
    #3
  4. > On Tue, 03 Feb 2004 00:09:16 +0900, Nathaniel Talbott wrote:
    >> The noise below is
    >> somehow being caused by your use of Test::Unit. Why is...
    >>
    >>> <["abababab", "ab"]> expected but was

    >>
    >> ..an array being compared to...
    >>
    >>> <#<RuntimeError: integrity: expected "a . b", got "a b a b a b a b" at
    >>> line 4> /home/

    >>
    >> .. a RuntimeError? Without seeing at least the structure of your code,
    >> I can't figure out what's going on, but I don't think it's a Test::Unit
    >> issue. I can only make it so smart :)


    I have made my own 'assert_regex' method, which checks several things.
    In the above case my regexp engine returns too quick without consuming
    all of the integrity data.

    def assert_regex(expected, regexp_string, input_string, options={})
    check_options(options, :integrity_heredoc)
    heredoc = options[:integrity_heredoc]
    integrity_ary = (heredoc == nil) ? nil : heredoc2ary(heredoc)
    actual = nil
    actual_str = "nil"
    begin
    m = compile(regexp_string).match_integrity(
    input_string, integrity_ary)
    actual = m.to_a if m
    actual_str = actual.inspect
    rescue => e
    actual = e.inspect + " " + e.backtrace.join("\n")
    actual_str = actual
    end
    full_message = "<#{expected.inspect}> expected but was\n<#{actual_str}>."
    assert_block(full_message) { expected == actual }
    end


    Could the problem be located here ?

    --
    Simon Strandgaard
    Simon Strandgaard, Feb 2, 2004
    #4
  5. On Mon, 02 Feb 2004 16:51:53 +0100, Simon Strandgaard wrote:

    > rescue => e
    > actual = e.inspect + " " + e.backtrace.join("\n")


    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Ok I found my problem.
    don't output the backtrace!
    Solved


    > actual_str = actual
    > end



    Thanks for the help :)


    --
    Simon Strandgaard
    Simon Strandgaard, Feb 2, 2004
    #5
  6. On Feb 2, 2004, at 11:04, Simon Strandgaard wrote:

    > On Mon, 02 Feb 2004 16:51:53 +0100, Simon Strandgaard wrote:
    >
    >> rescue => e
    >> actual = e.inspect + " " + e.backtrace.join("\n")

    >
    > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    > Ok I found my problem.
    > don't output the backtrace!
    > Solved
    >
    >
    >> actual_str = actual
    >> end

    >
    >
    > Thanks for the help :)


    We all have those days... :)


    Nathaniel

    <:((><
    Nathaniel Talbott, Feb 2, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VvanN
    Replies:
    5
    Views:
    475
    Phlip
    Apr 28, 2006
  2. Bill David
    Replies:
    2
    Views:
    261
    Arne Vajhøj
    Jun 18, 2008
  3. Simon Strandgaard
    Replies:
    14
    Views:
    173
    Nathaniel Talbott
    Aug 16, 2004
  4. timr
    Replies:
    2
    Views:
    151
  5. Mark
    Replies:
    2
    Views:
    385
Loading...

Share This Page