[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.3.4-50-g7610c46



The following commit has been merged in the master branch:
commit 0711d076a9087f39b058ba87a0be3940329ad414
Author: Raphael Geissert <atomo64@gmail.com>
Date:   Sat Mar 20 19:21:42 2010 -0600

    Rename the Lintian::Command::Simple functions/methods
    
    The names were unnecessarily confusing.

diff --git a/lib/Lintian/Command/Simple.pm b/lib/Lintian/Command/Simple.pm
index 2c5aab1..2514d79 100644
--- a/lib/Lintian/Command/Simple.pm
+++ b/lib/Lintian/Command/Simple.pm
@@ -26,19 +26,19 @@ Lintian::Command::Simple - Run commands without pipes
 
     use Lintian::Command::Simple;
 
-    Lintian::Command::Simple::exec("echo", "hello world");
+    Lintian::Command::Simple::run("echo", "hello world");
 
     # Start a command in the background:
-    Lintian::Command::Simple::fork("sleep", 10);
+    Lintian::Command::Simple::background("sleep", 10);
     print (Lintian::Command::Simple::wait())? "success" : "failure";
 
     # Using the OO interface
 
     my $cmd = Lintian::Command::Simple->new();
 
-    $cmd->exec("echo", "hello world");
+    $cmd->run("echo", "hello world");
 
-    $cmd->fork("sleep", 10);
+    $cmd->background("sleep", 10);
     print ($cmd->wait())? "success" : "failure";
 
 
@@ -71,7 +71,7 @@ sub new {
     return $self;
 }
 
-=item exec(command, argument  [, ...])
+=item run(command, argument  [, ...])
 
 Executes the given C<command> with the given arguments and returns the
 status code as one would see it from a shell script.
@@ -81,7 +81,7 @@ CORE::system() function is the way the return status is reported.
 
 =cut
 
-sub exec {
+sub run {
     my $self;
 
     if (ref $_[0]) {
@@ -98,7 +98,7 @@ sub exec {
     return $? >> 8;
 }
 
-=item fork(command, argument  [, ...])
+=item background(command, argument  [, ...])
 
 Executes the given C<command> with the given arguments asynchronously
 and returns the process id of the child process.
@@ -109,7 +109,7 @@ calling wait() to reap the previous command.
 
 =cut
 
-sub fork {
+sub background {
     my $self;
 
     if (ref $_[0]) {
@@ -149,7 +149,7 @@ a child of the current process) returns. If C<pid> is not specified, it
 waits for any child process to finish and returns.
 
 When called as a method:
-It takes no argument. It waits for the previously fork()ed process to
+It takes no argument. It waits for the previously background()ed process to
 return.
 
 The return value is either -1, probably indicating an error, or the
@@ -263,7 +263,7 @@ sub wait {
 =item pid()
 
 Only available under the OO interface, it returns the pid of a
-fork()ed process.
+background()ed process.
 
 After calling wait(), this method always returns undef.
 
@@ -278,7 +278,7 @@ sub pid {
 =item status()
 
 Only available under the OO interface, it returns the return status of
-the fork()ed or exec()uted process.
+the background()ed or run()-ran process.
 
 When used on async processes, it is only defined after calling wait().
 
@@ -315,7 +315,7 @@ __END__
 
 Provide the necessary methods to modify the environment variables of
 the to-be-executed commands.  This would let us drop C<system_env> (from
-lib/Util.pm) and make C<exec> more useful.
+lib/Util.pm) and make C<run> more useful.
 
 =head1 NOTES
 
@@ -334,7 +334,7 @@ object that started the reaped process won't be able to determine the
 return status, which can affect the rest of the application.
 
 As a general advise, the procedural and OO interfaces should not be
-combined when using fork(). Unless, of course, you are calling wait()
+combined when using background(). Unless, of course, you are calling wait()
 with a hash ref.
 
 =head1 AUTHOR
diff --git a/t/scripts/Lintian/Command/Simple/01-basic.t b/t/scripts/Lintian/Command/Simple/01-basic.t
index 06ba8c1..e78b3f2 100644
--- a/t/scripts/Lintian/Command/Simple/01-basic.t
+++ b/t/scripts/Lintian/Command/Simple/01-basic.t
@@ -6,5 +6,5 @@ use Test::More tests => 3;
 
 BEGIN { use_ok('Lintian::Command::Simple'); }
 
-is(Lintian::Command::Simple::exec("true"), 0, 'Basic exec (true)');
-is(Lintian::Command::Simple::exec("false"), 1, 'Basic exec (false)');
+is(Lintian::Command::Simple::run("true"), 0, 'Basic run (true)');
+is(Lintian::Command::Simple::run("false"), 1, 'Basic run (false)');
diff --git a/t/scripts/Lintian/Command/Simple/02-OO-basic.t b/t/scripts/Lintian/Command/Simple/02-OO-basic.t
index b814a53..40cf423 100644
--- a/t/scripts/Lintian/Command/Simple/02-OO-basic.t
+++ b/t/scripts/Lintian/Command/Simple/02-OO-basic.t
@@ -10,5 +10,5 @@ my $cmd;
 
 ok(eval { $cmd = Lintian::Command::Simple->new(); }, 'Create');
 
-is($cmd->exec("true"), 0, 'Basic exec (true)');
-is($cmd->exec("false"), 1, 'Basic exec (false)');
+is($cmd->run("true"), 0, 'Basic run (true)');
+is($cmd->run("false"), 1, 'Basic run (false)');
diff --git a/t/scripts/Lintian/Command/Simple/03-background.t b/t/scripts/Lintian/Command/Simple/03-background.t
index a4eea79..ab4286c 100644
--- a/t/scripts/Lintian/Command/Simple/03-background.t
+++ b/t/scripts/Lintian/Command/Simple/03-background.t
@@ -8,24 +8,24 @@ use Lintian::Command::Simple;
 
 my $pid;
 
-$pid = Lintian::Command::Simple::fork("true");
-cmp_ok($pid, '>', 0, 'Basic fork (true)');
+$pid = Lintian::Command::Simple::background("true");
+cmp_ok($pid, '>', 0, 'Basic background (true)');
 
 is(waitpid($pid, 0), $pid, "Waiting for pid");
 is($?, 0, "Return status is 0");
 
 # Again but using helper function
 
-$pid = Lintian::Command::Simple::fork("true");
-cmp_ok($pid, '>', 0, 'Basic fork (true), take two');
+$pid = Lintian::Command::Simple::background("true");
+cmp_ok($pid, '>', 0, 'Basic background (true), take two');
 
 is(Lintian::Command::Simple::wait($pid), 0, "Waiting and checking return status");
 is(waitpid($pid, 0), -1, "Process was really reaped");
 
 # One more time, but without passing a pid to wait()
 
-$pid = Lintian::Command::Simple::fork("true");
-cmp_ok($pid, '>', 0, 'Basic fork (true), take three');
+$pid = Lintian::Command::Simple::background("true");
+cmp_ok($pid, '>', 0, 'Basic background (true), take three');
 
 is(Lintian::Command::Simple::wait(), 0, "Waiting and checking \$? of any child");
 is(wait(), -1, "Process was really reaped");
diff --git a/t/scripts/Lintian/Command/Simple/04-OO-background.t b/t/scripts/Lintian/Command/Simple/04-OO-background.t
index 48eb766..56c48bd 100644
--- a/t/scripts/Lintian/Command/Simple/04-OO-background.t
+++ b/t/scripts/Lintian/Command/Simple/04-OO-background.t
@@ -10,17 +10,17 @@ my ($cmd, $pid);
 
 $cmd = Lintian::Command::Simple->new();
 
-$pid = $cmd->fork("true");
+$pid = $cmd->background("true");
 
-cmp_ok($pid, '>', 0, 'Basic fork (true)');
+cmp_ok($pid, '>', 0, 'Basic background (true)');
 is(waitpid($pid, 0), $pid, "Waiting for pid");
 is($?, 0, "Return status is 0");
 
 # Again but using helper function
 
 $cmd = Lintian::Command::Simple->new();
-$pid = $cmd->fork("true");
+$pid = $cmd->background("true");
 
-cmp_ok($pid, '>', 0, 'Basic fork (true), take two');
+cmp_ok($pid, '>', 0, 'Basic background (true), take two');
 is($cmd->wait(), 0, "Waiting and checking return status");
 is(waitpid($pid, 0), -1, "Process was really reaped");
diff --git a/t/scripts/Lintian/Command/Simple/05-OO-errors.t b/t/scripts/Lintian/Command/Simple/05-OO-errors.t
index d70cc8b..abb385c 100644
--- a/t/scripts/Lintian/Command/Simple/05-OO-errors.t
+++ b/t/scripts/Lintian/Command/Simple/05-OO-errors.t
@@ -12,7 +12,7 @@ my ($cmd, $pid);
 # OO's interface wait() doesn't reap it (because the OO interface
 # should only deal with any command started with it)
 
-$pid = Lintian::Command::Simple::fork("true");
+$pid = Lintian::Command::Simple::background("true");
 
 $cmd = Lintian::Command::Simple->new();
 
@@ -24,8 +24,8 @@ is(Lintian::Command::Simple::wait($pid), 0, "Checking \$? of the started child")
 
 $cmd = Lintian::Command::Simple->new();
 
-cmp_ok($cmd->fork("true"), '>', 0, 'Running one job is ok');
-is($cmd->fork("false"), -1, 'Running a second job is not');
+cmp_ok($cmd->background("true"), '>', 0, 'Running one job is ok');
+is($cmd->background("false"), -1, 'Running a second job is not');
 
 is($cmd->wait(), 0, "We wait() for the 'true' job");
 is(Lintian::Command::Simple::wait(), -1, "No other job is running");
@@ -34,18 +34,18 @@ is(Lintian::Command::Simple::wait(), -1, "No other job is running");
 
 $cmd = Lintian::Command::Simple->new();
 
-cmp_ok($cmd->fork("true"), '>', 0, 'Running one job is ok');
+cmp_ok($cmd->background("true"), '>', 0, 'Running one job is ok');
 is($cmd->wait(), 0, "We wait() for the 'true' job");
 
-cmp_ok($cmd->fork("false"), '>', 0, 'Running a second job is ok after wait()ing');
+cmp_ok($cmd->background("false"), '>', 0, 'Running a second job is ok after wait()ing');
 is($cmd->wait(), 1, "We wait() for the 'true' job");
 
-# Just like the above cases, but combining a fork and an exec
+# Just like the above cases, but combining a background and an exec
 
 $cmd = Lintian::Command::Simple->new();
 
-cmp_ok($cmd->fork("true"), '>', 0, 'Running one job is ok');
-is($cmd->exec("false"), -1, 'Running exec() before wait()ing is not');
+cmp_ok($cmd->background("true"), '>', 0, 'Running one job is ok');
+is($cmd->run("false"), -1, 'Running exec() before wait()ing is not');
 
 is($cmd->wait(), 0, "We wait() for the 'true' job");
 
@@ -54,7 +54,7 @@ is($cmd->wait(), 0, "We wait() for the 'true' job");
 
 $cmd = Lintian::Command::Simple->new();
 
-$cmd->fork("true");
+$cmd->background("true");
 
 is(Lintian::Command::Simple::wait(), 0, 'Another wait() call reaps an OO job');
 
@@ -63,5 +63,5 @@ is($cmd->wait(), -1, "We only know the job is gone, no return status");
 # But it was reaped anyway, so make sure it is possible to start
 # another job via the same object.
 
-cmp_ok($cmd->fork("true"), '>', 0, 'Running a second job is ok after foreign wait()');
+cmp_ok($cmd->background("true"), '>', 0, 'Running a second job is ok after foreign wait()');
 is($cmd->wait(), 0, "We wait() for the 'true' job");
diff --git a/t/scripts/Lintian/Command/Simple/06-return-status.t b/t/scripts/Lintian/Command/Simple/06-return-status.t
index 981ecfb..2262091 100644
--- a/t/scripts/Lintian/Command/Simple/06-return-status.t
+++ b/t/scripts/Lintian/Command/Simple/06-return-status.t
@@ -8,12 +8,12 @@ use Lintian::Command::Simple;
 
 my $pid;
 
-$pid = Lintian::Command::Simple::fork("false");
+$pid = Lintian::Command::Simple::background("false");
 
 is(Lintian::Command::Simple::wait($pid), 1, "Waiting with pid and checking return status");
 
 # One more time, but without passing a pid to wait()
 
-$pid = Lintian::Command::Simple::fork("false");
+$pid = Lintian::Command::Simple::background("false");
 
 is(Lintian::Command::Simple::wait(), 1, "Waiting without pid and checking return status");
diff --git a/t/scripts/Lintian/Command/Simple/07-OO-other-methods.t b/t/scripts/Lintian/Command/Simple/07-OO-other-methods.t
index 0d1f01c..fd563c6 100644
--- a/t/scripts/Lintian/Command/Simple/07-OO-other-methods.t
+++ b/t/scripts/Lintian/Command/Simple/07-OO-other-methods.t
@@ -12,10 +12,10 @@ $cmd = Lintian::Command::Simple->new();
 
 # pid():
 
-is($cmd->pid(), undef, 'pid() returns undef without fork()');
+is($cmd->pid(), undef, 'pid() returns undef without background()');
 
-$pid = $cmd->fork("true");
-is($cmd->pid(), $pid, 'pid() returns PID after fork()');
+$pid = $cmd->background("true");
+is($cmd->pid(), $pid, 'pid() returns PID after background()');
 
 $cmd->wait();
 
@@ -25,27 +25,27 @@ is($cmd->pid(), undef, 'pid() returns undef after wait()');
 
 $cmd = Lintian::Command::Simple->new();
 
-is($cmd->status(), undef, 'status() returns undef without fork()');
+is($cmd->status(), undef, 'status() returns undef without background()');
 
-$cmd->fork("true");
+$cmd->background("true");
 is($cmd->status(), undef, 'status() returns undef without wait()');
 
 $cmd->wait();
 
 is($cmd->status(), 0, 'status() is 0 after wait()');
 
-$cmd->fork("false");
-is($cmd->status(), undef, 'status() returns undef after another fork()');
+$cmd->background("false");
+is($cmd->status(), undef, 'status() returns undef after another background()');
 
 $cmd->wait();
 
 is($cmd->status(), 1, 'status() is 1 after wait()');
 
-# status() with exec()
+# status() with run()
 
 $cmd = Lintian::Command::Simple->new();
 
-$cmd->exec("true");
-is($cmd->status(), 0, "status() returns 0 for exec(true)");
-$cmd->exec("false");
-is($cmd->status(), 1, "status() returns 1 for exec(false)");
+$cmd->run("true");
+is($cmd->status(), 0, "status() returns 0 for run(true)");
+$cmd->run("false");
+is($cmd->status(), 1, "status() returns 1 for run(false)");
diff --git a/t/scripts/Lintian/Command/Simple/08-multiple-jobs.t b/t/scripts/Lintian/Command/Simple/08-multiple-jobs.t
index e90a5b3..9cf1e50 100644
--- a/t/scripts/Lintian/Command/Simple/08-multiple-jobs.t
+++ b/t/scripts/Lintian/Command/Simple/08-multiple-jobs.t
@@ -12,7 +12,7 @@ my %jobs;
 
 while ($c) {
     $cmd = Lintian::Command::Simple->new();
-    $cmd->fork("sleep", 1);
+    $cmd->background("sleep", 1);
     $jobs{$c} = $cmd;
     $c--;
 }
@@ -28,7 +28,7 @@ is($c, 4, "4 jobs were started, 4 reaped");
 
 while ($c) {
     $cmd = Lintian::Command::Simple->new();
-    $cmd->fork("sleep", 1);
+    $cmd->background("sleep", 1);
     $jobs{"Job $c"} = $cmd;
     $c--;
 }
@@ -45,7 +45,7 @@ is($c, 4, "4 more jobs were started, 4 reaped");
 # (i.e. undef is returned and no process is reaped)
 
 %jobs = ();
-my $pid = Lintian::Command::Simple::fork("true");
+my $pid = Lintian::Command::Simple::background("true");
 is(Lintian::Command::Simple::wait(\%jobs), undef,
     "With an empty hash ref, wait() returns undef");
 
@@ -55,7 +55,7 @@ is(Lintian::Command::Simple::wait($pid), 0,
 # Again but now in list context
 
 %jobs = ();
-$pid = Lintian::Command::Simple::fork("true");
+$pid = Lintian::Command::Simple::background("true");
 is(my @list = Lintian::Command::Simple::wait(\%jobs), 0,
     "With an empty hash ref, in list context wait() returns null");
 

-- 
Debian package checker


Reply to: