logo       

Re: [PATCH] Forking tests with Test::More: msg#00140

Subject: Re: [PATCH] Forking tests with Test::More
Without saying you shouldn't be sending them here, but as an aside...

Who told you to send patches to the list?

Is there a reason that the rt.cpan.org queue is no longer useful?

Adam K

Tassilo von Parseval wrote:
Hi,

I was told that Test::More patches should now go to this list so here we
go.

The attached patch serves as a draft for enabling test-scripts that fork
without the test-counter getting confused. It does so by using a
Storable imaged shared between the processes. The patch however does
need some modification because there's a race condition in there. It
uses lock_nstore and lock_retrieve to store the current test-metrics
thusly:

+sub _inc_testcount {
+    my $self = shift;
+
+    if( not $self->{Forked} ) {
+   lock $self->{Curr_Test};
+   $self->{Curr_Test}++;
+   return;
+    }
+
+    # we are running in forked mode, therefore
+    # get data from disk, modify and write back
+
+    my $stats = lock_retrieve( $self->{Forked} );
+    $self->{Curr_Test} = ++$stats->{Curr_Test};
+    $self->{Test_Results} = $stats->{Test_Results};
+    lock_nstore( $stats => $self->{Forked} );
+}

This is not quite correct. Instead, the member $self->{Forked} should be
turned into a rw-filehandle to the storable image (it is the path to the
image right now) and _inc_testcount() would become something like that:

    ...
    # we are running in forked mode, therefore
    # get data from disk, modify and write back
# enter criticial region: lock $self->{Forked}, LOCK_EX;
    my $stats = fd_retrieve($self->{Forked});
    $self->{Curr_Test} = ++$stats->{Curr_Test};
    $self->{Test_Results} = $stats->{Test_Results};
    nstore_fd( $stats => $self->{Forked} );
    lock $self->{Forked}, LOCK_UN;
# criticial region left

A similar approach is needed for _store() and essentially for everything
that now uses lock_nstore/lock_retrieve.

Also, a test-case for this feature is tricky to conceive as
Test::Builder::Tester can't be used here. I supplied one but it's quite
messy.

I am right now in the middle of relocating to NY so I don't have the
time to do these modifications myself so maybe someone with more time on
his hands could look after that. It's not so tricky and mostly involves
some local changes to the enclosed patch.

Cheers,
Tassilo



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe