commit c13edd93d68415fd4dce8af5c1258001b1d6194c
parent 15510c6735f851fe337e83e8318e689e561d12b8
Author: Andreas Guldstrand <andreas.guldstrand@gmail.com>
Date: Wed, 11 May 2016 22:41:06 +0000
SBO::Lib: add _race::cond subroutine
for identifying, documenting, and testing race conditions
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
@@ -115,6 +115,10 @@ our $tempdir = tempdir(CLEANUP => 1, DIR => $tmpd);
# t/01-test.t
our $pkg_db = '/var/log/packages';
+# _race::cond will allow both documenting and testing race conditions
+# by overriding its implementation for tests
+sub _race::cond { return }
+
# subroutine for throwing internal script errors
sub script_error {
if (@_) {
@@ -139,6 +143,7 @@ sub open_fh {
}
my ($file, $op) = @_;
my $fh;
+ _race::cond 'possibly $file has been deleted between -f test and now';
unless (open $fh, $op, $file) {
my $warn = "Unable to open $file.\n";
my $exit = _ERR_OPENFH;