[Midnightbsd-cvs] mports: lib/Magus: Start of the outcome rules.

ctriv at midnightbsd.org ctriv at midnightbsd.org
Thu Sep 13 23:01:12 EDT 2007


Log Message:
-----------
Start of the outcome rules.

Added Files:
-----------
    mports/Tools/lib/Magus:
        OutcomeRules.pm (r1.1)
    mports/Tools/lib/Magus/OutcomeRules:
        Base.pm (r1.1)

-------------- next part --------------
--- /dev/null
+++ Tools/lib/Magus/OutcomeRules.pm
@@ -0,0 +1,52 @@
+package Magus::OutcomeRules;
+#
+# Copyright (c) 2007 Chris Reinhardt. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# 1. Redistributions of source code must retain the above copyright notice
+#    this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $MidnightBSD: mports/Tools/lib/Magus/OutcomeRules.pm,v 1.1 2007/09/14 03:01:10 ctriv Exp $
+#
+# MAINTAINER=   ctriv at MidnightBSD.org
+#
+
+package Magus::OutcomeRules::fake;
+
+use base qw(Magus::OutcomeRules::Base);
+
+sub IncompleteInstall :error {
+  m/^\t	.* not installed.\n$/m 
+    && return "Some file in the plist wasn't installed in the fake dir or the final dir.";
+}
+
+sub FakeDestdirInFile :error {
+  m/contains the fake destdir./s 
+    && return "Some file contained the fake destdir.";
+}
+
+1;
+
+    
+
+1;
+__END__
+
--- /dev/null
+++ Tools/lib/Magus/OutcomeRules/Base.pm
@@ -0,0 +1,125 @@
+package Magus::OutcomeRules::Base;
+#
+# Copyright (c) 2007 Chris Reinhardt. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# 1. Redistributions of source code must retain the above copyright notice
+#    this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $MidnightBSD: mports/Tools/lib/Magus/OutcomeRules/Base.pm,v 1.1 2007/09/14 03:01:10 ctriv Exp $
+#
+# MAINTAINER=   ctriv at MidnightBSD.org
+#
+
+use strict;
+use warnings;
+use Attribute::Handlers;
+
+use base qw(Class::Data::Inheritable);
+
+
+=head1 NAME 
+
+Magus::OutcomeRules
+
+=head1 SYNOPSIS
+
+  
+=head1 DESCRIPTION
+
+This module contains the individual rules used to analyze the output of a port.
+
+=cut
+
+
+__PACKAGE__->mk_classdata('error_rules');
+__PACKAGE__->mk_classdata('warning_rules');
+
+#
+# __PACKAGE__->fail($msg, $code)
+#
+
+
+sub error :ATTR(CODE) {
+  my ($class, $sym, $code) = @_;
+  
+  my $rules = $class->error_rules;
+  (my $phase = $class) =~ s/^.*:://;
+  
+  my $entry = {
+    name  => *$sym{NAME}, # evil grin :->
+    phase => $phase,
+    code  => $code,
+  };
+  
+  push(@$rules, $entry);
+  
+  $class->error_rules($rules);
+}
+
+sub warning :ATTR(CODE) {
+  my ($class, $sym, $code) = @_;
+  
+  my $rules = $class->warning_rules;
+  (my $phase = $class) =~ s/^.*:://;
+  
+  my $entry = {
+    name  => *$sym{NAME}, # evil grin :->
+    phase => $phase,
+    code  => $code,
+  };
+   
+  push(@$rules, $code);
+  
+  $class->warning_rules($rules);
+}
+
+sub test {
+  my ($class, $text) = @_;
+  
+  local $_ = $text;
+  
+  my %result = (
+    summary => 'pass'   
+  );
+  
+  foreach my $rule (@{$class->error_rules}) {
+    if (my $msg = $rule->()) {
+      $result{summary} = 'fail';
+      push(@{$result{errors}}, $msg);
+    }
+  }
+  
+  foreach my $rule (@{$class->warning_rules}) {
+    if (my $msg = $rule->()) {
+      push(@{$result{warnings}}, $msg);
+    }
+  }
+
+  return \%result;
+}
+
+
+
+
+1;
+__END__
+


More information about the Midnightbsd-cvs mailing list