Coder Social home page Coder Social logo

test-sharedfork's Introduction

NAME

Test::SharedFork - fork test

SYNOPSIS

use Test::More tests => 200;
use Test::SharedFork;

my $pid = fork();
if ($pid == 0) {
    # child
    ok 1, "child $_" for 1..100;
} elsif ($pid) {
    # parent
    ok 1, "parent $_" for 1..100;
    waitpid($pid, 0);
} else {
    die $!;
}

DESCRIPTION

Test::SharedFork is utility module for Test::Builder.

This module makes fork(2) safety in your test case.

This module merges test count with parent process & child process.

LIMITATIONS

This version of the Test::SharedFork does not support ithreads, because threads::shared conflicts with Storable.

AUTHOR

Tokuhiro Matsuno <tokuhirom slkjfd gmail.com>

yappo

THANKS TO

kazuhooku

konbuizm

SEE ALSO

Test::TCP, Test::Fork, Test::MultiFork

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

test-sharedfork's People

Contributors

berekuk avatar charsbar avatar chorny avatar exodist avatar haarg avatar hoelzro avatar lestrrat avatar neilb avatar perlover avatar rwhitworth avatar schwern avatar tokuhirom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

test-sharedfork's Issues

Cygwin tests stalling

On Cygwin 64-bit I had to make the following changes in order to convince the tests to run. Note, the test were never failing, but they would stall out and completely pause, with no chance of success or failure. This is likely why you aren't receiving many CPAN smoker reports about Test::SharedFork on Cygwin.

In 01_simple.t I had to adjust both the sleep(rand()/100) lines to instead just sleep for 1 second. This made the test a bit slow to run, but allowed the test to pass.

In 02_fork_method.t I had to add sleep(1) to both loops, below the 'ok 1' lines. This made the test a bit slow as well, but allowed the test to pass.

All other tests look to be working fine once those two changes are made.

Additional information about the environment:
Windows 7 64-bit
perl 5.14.4 (cygwin-thread-multi)
Cygwin 64-bit using cygwin.dll version 1.7.28 compiled 2014-02-09
Test::SharedFork 0.23

Test failures with with Test-Simple-1.302014_003

Following failure happens on my smokers:

#   Failed test 'Test::Builder->is_passing should be falsy after a failing test'
#   at t/12_is_passing.t line 42.

#   Failed test 'Test::Builder->is_passing should still be falsy, even after a passing test post-fail'
#   at t/12_is_passing.t line 48.
# ok 1
# Looks like you failed 2 tests of 4.
IPC Fatal Error: Leftover files in the directory (/var/tmp/cpansmoker-1023/2016042318/test2-2850-zHj3cp/2850-0-2-2852-0-1-Test2-Event-Ok.ready)!
IPC Fatal Error: Leftover files in the directory (/var/tmp/cpansmoker-1023/2016042318/test2-2850-zHj3cp/2850-0-2-2855-0-1-Test2-Event-Ok.ready)!
IPC Fatal Error: Leftover files in the directory (/var/tmp/cpansmoker-1023/2016042318/test2-2850-zHj3cp/2850-0-2-2852-0-2-Test2-Event-Diag.ready)!
Could not remove IPC temp dir (/var/tmp/cpansmoker-1023/2016042318/test2-2850-zHj3cp) at /home/cpansand/.cpan/build/2016042318/Test-Simple-1.302014_003-BJKmpx/blib/lib/Test2/IPC/Driver/Files.pm line 301 during global destruction.
t/12_is_passing.t ........
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/4 subtests

06_fail_lineno.t fails on Windows due to path separator

Using File::Spec::Functions::catfile ensures correct path separator is used in the pattern:

use strict;
use warnings;
use Test::More tests => 2;
use Test::SharedFork;
use File::Spec::Functions qw/ catfile /;
use File::Temp qw/tempfile/;

local $ENV{LANG} = "C";

my $out = do {
    open my $fh, ">", \my $out or die $!;
    my $test = Test::Builder->create();
    $test->output($fh);
    $test->failure_output($fh);
    $test->todo_output($fh);
    $test->ok(0);
    $out;
};

unlike($out, qr{lib/Test/SharedFork});
{
    my $path = catfile(qw(t 06_fail_lineno.t));
    like($out, qr{\Q$path\E line \d+\.});
}

Suggestion: Improve Abstract

The current abstract of:

fork test

Is a bit simplistic and lacks expressiveness.

This is noticed as we've been replicating the description verbatim downstream, and its lack of detail has come to the attention of QA: https://bugs.gentoo.org/689454

Comments in a related bug suggest an alternative of:

Ensure that tests work correctly when fork() is used

Which seems appropriate.

If this wording is not adequate for you, please try to find an alternative that fits under 80 characters, which will allow us to avoid subsequent shortening, and continue using the description verbatim ( which helps with automation ).

ExtUtils::MakeMaker version

I noticed that the recent switch to EUMM requires version 6.64. Is there a specific need to use 6.64 or will earlier version(s) work correctly also?

0.35: some fails in test site

+ /usr/bin/make -O -j48 V=1 VERBOSE=1 test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
# Test::Builder::VERSION: 1.302175
t/00_compile.t ........... ok
t/01_simple.t ............ ok
t/02_fork_method.t ....... ok
t/03_toomany_run.t ....... ok
t/04_test_before_fork.t .. ok
t/05_nest.t .............. ok
t/06_fail_lineno.t ....... ok
t/07_lazy_load.t ......... ok
t/08_threads.t ........... skipped: Not implemented yet
t/09_very_simple.t ....... ok

    #   Failed test 'child three'
    #   at t/nest/subtest.ttt line 14.
    # Looks like you failed 1 test of 6.

#   Failed test 'foo'
#   at t/nest/subtest.ttt line 19.
# Looks like you failed 1 test of 1.
t/10_subtest.t ........... ok
t/11_failure_location.t .. ok
# ok 1
# not ok 2
# #   Failed test at t/12_is_passing.t line 18.
# ok 3
t/12_is_passing.t ........ ok
All tests successful.

Test Summary Report
-------------------
t/10_subtest.t         (Wstat: 0 Tests: 1 Failed: 0)
  TODO passed:   1
Files=13, Tests=137, 42 wallclock secs ( 0.10 usr  0.07 sys +  1.10 cusr  1.08 csys =  2.35 CPU)
Result: PASS

I'm not sure is that expected result dso better is to ask :)

Despite those fails test suite finishes with exiit code 0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.