rutema 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +8 -0
- data/Manifest.txt +14 -21
- data/README.txt +3 -2
- data/Rakefile +3 -2
- data/bin/rutemaweb +3 -3
- data/lib/rutema/historian.rb +6 -0
- data/lib/rutema/reporter_ar.rb +6 -2
- data/lib/rutema/system.rb +30 -8
- data/lib/rutemaweb/{htdocs → public}/bg_menu.gif +0 -0
- data/lib/rutemaweb/{htdocs → public}/bg_submenu.gif +0 -0
- data/lib/rutemaweb/{htdocs → public}/run_error.png +0 -0
- data/lib/rutemaweb/{htdocs → public}/run_ok.png +0 -0
- data/lib/rutemaweb/{htdocs → public}/run_warn.png +0 -0
- data/lib/rutemaweb/{htdocs → public}/step_error.png +0 -0
- data/lib/rutemaweb/{htdocs → public}/step_ok.png +0 -0
- data/lib/rutemaweb/{htdocs → public}/step_warn.png +0 -0
- data/lib/rutemaweb/{htdocs → public}/style.css +3 -3
- data/lib/rutemaweb/{htdocs → public}/tie_logo.gif +0 -0
- data/lib/rutemaweb/ramaze_controller.rb +164 -0
- data/lib/rutemaweb/view/layout.rhtml +47 -0
- data/test/distro_test/config/database.rutema +0 -1
- data/test/rutema.rutema +3 -0
- data/test/rutema.spec +9 -0
- metadata +27 -15
- data/lib/rutemaweb/rutemaweb.rb +0 -245
    
        data/History.txt
    CHANGED
    
    | @@ -1,3 +1,11 @@ | |
| 1 | 
            +
            == 0.5.0 / 2008-02-26
         | 
| 2 | 
            +
            * activerecord reporter is now loaded by default (no need to require it in the configuration file)
         | 
| 3 | 
            +
            * bugfix: step names correctly written in the database
         | 
| 4 | 
            +
            * The web frontend now uses Ramaze
         | 
| 5 | 
            +
            * using patir-0.5.3 because of the chdir bugfixes
         | 
| 6 | 
            +
            * rutema can now test itself! rutemax and rutemah return meaningful exit codes. So there, we do it our own dogfood
         | 
| 7 | 
            +
            * lots more documentation on usage and how to build a parser
         | 
| 8 | 
            +
             | 
| 1 9 | 
             
            == 0.4.3 / 2008-02-25
         | 
| 2 10 | 
             
            * fixed bug in rutemax when the activerecord reporter is used, where the database was not created relative to the configuration entry
         | 
| 3 11 | 
             
            * fixed bug in rutemah where the report was not printed (doh!)
         | 
    
        data/Manifest.txt
    CHANGED
    
    | @@ -13,32 +13,25 @@ lib/rutema/reporter.rb | |
| 13 13 | 
             
            lib/rutema/reporter_ar.rb
         | 
| 14 14 | 
             
            lib/rutema/historian.rb
         | 
| 15 15 | 
             
            lib/rutema/model.rb
         | 
| 16 | 
            -
            lib/rutemaweb/ | 
| 17 | 
            -
            lib/rutemaweb/ | 
| 18 | 
            -
            lib/rutemaweb/ | 
| 19 | 
            -
            lib/rutemaweb/ | 
| 20 | 
            -
            lib/rutemaweb/ | 
| 21 | 
            -
            lib/rutemaweb/ | 
| 22 | 
            -
            lib/rutemaweb/ | 
| 23 | 
            -
            lib/rutemaweb/ | 
| 24 | 
            -
            lib/rutemaweb/ | 
| 25 | 
            -
            lib/rutemaweb/ | 
| 26 | 
            -
            lib/rutemaweb/ | 
| 27 | 
            -
            lib/rutemaweb/ | 
| 28 | 
            -
            lib/rutemaweb/htdocs/bg_submenu.gif
         | 
| 29 | 
            -
            lib/rutemaweb/htdocs/run_error.png
         | 
| 30 | 
            -
            lib/rutemaweb/htdocs/run_ok.png
         | 
| 31 | 
            -
            lib/rutemaweb/htdocs/run_warn.png
         | 
| 32 | 
            -
            lib/rutemaweb/htdocs/step_error.png
         | 
| 33 | 
            -
            lib/rutemaweb/htdocs/step_ok.png
         | 
| 34 | 
            -
            lib/rutemaweb/htdocs/step_warn.png
         | 
| 35 | 
            -
            lib/rutemaweb/htdocs/style.css
         | 
| 36 | 
            -
            lib/rutemaweb/htdocs/tie_logo.gif
         | 
| 16 | 
            +
            lib/rutemaweb/ramaze_controller.rb
         | 
| 17 | 
            +
            lib/rutemaweb/public/bg_menu.gif
         | 
| 18 | 
            +
            lib/rutemaweb/public/bg_submenu.gif
         | 
| 19 | 
            +
            lib/rutemaweb/public/run_error.png
         | 
| 20 | 
            +
            lib/rutemaweb/public/run_ok.png
         | 
| 21 | 
            +
            lib/rutemaweb/public/run_warn.png
         | 
| 22 | 
            +
            lib/rutemaweb/public/step_error.png
         | 
| 23 | 
            +
            lib/rutemaweb/public/step_ok.png
         | 
| 24 | 
            +
            lib/rutemaweb/public/step_warn.png
         | 
| 25 | 
            +
            lib/rutemaweb/public/style.css
         | 
| 26 | 
            +
            lib/rutemaweb/public/tie_logo.gif
         | 
| 27 | 
            +
            lib/rutemaweb/view/layout.rhtml
         | 
| 37 28 | 
             
            test/test_configuration.rb
         | 
| 38 29 | 
             
            test/test_specification.rb
         | 
| 39 30 | 
             
            test/test_system.rb
         | 
| 40 31 | 
             
            test/test_historian.rb
         | 
| 41 32 | 
             
            test/test_reporter.rb
         | 
| 33 | 
            +
            test/rutema.rutema
         | 
| 34 | 
            +
            test/rutema.spec
         | 
| 42 35 | 
             
            test/samples/check.spec
         | 
| 43 36 | 
             
            test/samples/setup.spec
         | 
| 44 37 | 
             
            test/samples/teardown.spec
         | 
    
        data/README.txt
    CHANGED
    
    | @@ -16,6 +16,8 @@ For more information look at http://patir.rubyforge.org/rutema | |
| 16 16 | 
             
            * rutemah - a tool to create reports out of a test result database
         | 
| 17 17 | 
             
            * rutemaweb - a web frontend for the test result database
         | 
| 18 18 |  | 
| 19 | 
            +
            There is a bug in camping 1.5 (in camping/webrick.rb line 59 res should be resp) that prevents the stylesheet from loading
         | 
| 20 | 
            +
             | 
| 19 21 | 
             
            == SYNOPSIS:
         | 
| 20 22 |  | 
| 21 23 | 
             
            Once installed (which is simple) and configured (which can vary from simple to highly complex but is usually more complex than tying your shoelaces) you can do:
         | 
| @@ -31,13 +33,12 @@ rutemax -c sample.cfg unattended - to run all unattended tests | |
| 31 33 | 
             
            == REQUIREMENTS:
         | 
| 32 34 |  | 
| 33 35 | 
             
            * patir (http://patir.rubyforge.org)
         | 
| 34 | 
            -
            * highline (http://highline.rubyforge.org)
         | 
| 35 36 | 
             
            * mailfactory (http://rubyforge.org/projects/mailfactory/)
         | 
| 36 37 | 
             
            * activerecord (http://ar.rubyonrails.com/)
         | 
| 37 38 | 
             
            * sqlite3 (http://rubyforge.org/projects/sqlite-ruby/)
         | 
| 38 39 | 
             
            * camping (http://camping.rubyforge.org/)
         | 
| 39 40 | 
             
            * ruport (http://rubyreports.org/)
         | 
| 40 | 
            -
             | 
| 41 | 
            +
            * acts_as_reportable
         | 
| 41 42 | 
             
            == INSTALL:
         | 
| 42 43 |  | 
| 43 44 | 
             
            * gem install rutema
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -14,13 +14,14 @@ Hoe.new('rutema', "#{Rutema::Version::STRING}") do |p| | |
| 14 14 | 
             
              p.description = p.paragraphs_of('README.txt', 1..5).join("\n\n")
         | 
| 15 15 | 
             
              p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
         | 
| 16 16 | 
             
              p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
         | 
| 17 | 
            -
              p.extra_deps<<['patir',">=0. | 
| 17 | 
            +
              p.extra_deps<<['patir',">=0.5.2"]
         | 
| 18 18 | 
             
              p.extra_deps<<['highline']
         | 
| 19 19 | 
             
              p.extra_deps<<['mailfactory']
         | 
| 20 20 | 
             
              p.extra_deps<<['activerecord']
         | 
| 21 21 | 
             
              p.extra_deps<<['ruport']
         | 
| 22 22 | 
             
              p.extra_deps<<['acts_as_reportable']
         | 
| 23 | 
            -
              p.extra_deps<<[' | 
| 23 | 
            +
              p.extra_deps<<['ramaze']
         | 
| 24 | 
            +
              p.extra_deps<<['erubis']
         | 
| 24 25 | 
             
              p.spec_extras={:executables=>["rutemax","rutemah","rutemaweb"],
         | 
| 25 26 | 
             
                :default_executable=>"rutemax"}
         | 
| 26 27 | 
             
            end
         | 
    
        data/bin/rutemaweb
    CHANGED
    
    | @@ -1,9 +1,9 @@ | |
| 1 1 | 
             
            #  Copyright (c) 2007 Vassilis Rizopoulos. All rights reserved.
         | 
| 2 2 | 
             
            begin
         | 
| 3 | 
            -
              require 'rutemaweb/ | 
| 3 | 
            +
              require 'rutemaweb/ramaze_controller'
         | 
| 4 4 | 
             
            rescue LoadError
         | 
| 5 5 | 
             
              require 'rubygems'
         | 
| 6 | 
            -
              require 'rutemaweb/ | 
| 6 | 
            +
              require 'rutemaweb/ramaze_controller'
         | 
| 7 7 | 
             
            end
         | 
| 8 8 |  | 
| 9 | 
            -
             | 
| 9 | 
            +
            start_ramaze
         | 
    
        data/lib/rutema/historian.rb
    CHANGED
    
    | @@ -96,12 +96,18 @@ module Rutema | |
| 96 96 | 
             
                end
         | 
| 97 97 | 
             
                def connect
         | 
| 98 98 | 
             
                  ActiveRecord::Base.logger = @logger
         | 
| 99 | 
            +
                  if @configuration.source
         | 
| 99 100 | 
             
                    if File.exist?(@configuration.source)
         | 
| 100 101 | 
             
                      @logger.info("Connecting with database '#{@configuration.source}'")
         | 
| 101 102 | 
             
                      ActiveRecord::Base.establish_connection(:adapter=>"sqlite3", :database=>@configuration.source )
         | 
| 102 103 | 
             
                    else
         | 
| 103 104 | 
             
                      @logger.fatal("Could not find #{@configuration.source}")
         | 
| 105 | 
            +
                      exit 1
         | 
| 104 106 | 
             
                    end
         | 
| 107 | 
            +
                  else
         | 
| 108 | 
            +
                    @logger.fatal("No database source defined in the configuration")
         | 
| 109 | 
            +
                    exit 1
         | 
| 110 | 
            +
                  end
         | 
| 105 111 | 
             
                end
         | 
| 106 112 | 
             
              end
         | 
| 107 113 | 
             
            end
         | 
    
        data/lib/rutema/reporter_ar.rb
    CHANGED
    
    | @@ -14,7 +14,11 @@ module Rutema | |
| 14 14 | 
             
                  @logger=definition[:logger]
         | 
| 15 15 | 
             
                  @logger||=Patir.setup_logger
         | 
| 16 16 | 
             
                  raise "No database file defined" unless definition[:dbfile]
         | 
| 17 | 
            -
                   | 
| 17 | 
            +
                  unless definition[:dbfile]==":memory:"
         | 
| 18 | 
            +
                    @dbfile=File.expand_path(definition[:dbfile]) 
         | 
| 19 | 
            +
                  else
         | 
| 20 | 
            +
                    @dbfile=definition[:dbfile]
         | 
| 21 | 
            +
                  end
         | 
| 18 22 | 
             
                  connect
         | 
| 19 23 | 
             
                end
         | 
| 20 24 |  | 
| @@ -53,7 +57,7 @@ module Rutema | |
| 53 57 | 
             
                    end
         | 
| 54 58 | 
             
                    scenario.step_states.each do |number,step|
         | 
| 55 59 | 
             
                      st=Model::Step.new
         | 
| 56 | 
            -
                      st.name=step[: | 
| 60 | 
            +
                      st.name=step[:step_type]
         | 
| 57 61 | 
             
                      st.number=number
         | 
| 58 62 | 
             
                      st.status=step[:status].to_s
         | 
| 59 63 | 
             
                      st.output=step[:output]
         | 
    
        data/lib/rutema/system.rb
    CHANGED
    
    | @@ -4,7 +4,7 @@ require 'rexml/document' | |
| 4 4 |  | 
| 5 5 | 
             
            require 'rutema/specification'
         | 
| 6 6 | 
             
            require 'rutema/configuration'
         | 
| 7 | 
            -
            require 'rutema/ | 
| 7 | 
            +
            require 'rutema/reporter_ar'
         | 
| 8 8 |  | 
| 9 9 |  | 
| 10 10 | 
             
            require 'rubygems'
         | 
| @@ -15,8 +15,8 @@ module Rutema | |
| 15 15 | 
             
              #This module defines the version numbers for the library
         | 
| 16 16 | 
             
              module Version
         | 
| 17 17 | 
             
                MAJOR=0
         | 
| 18 | 
            -
                MINOR= | 
| 19 | 
            -
                TINY= | 
| 18 | 
            +
                MINOR=5
         | 
| 19 | 
            +
                TINY=0
         | 
| 20 20 | 
             
                STRING=[ MAJOR, MINOR, TINY ].join( "." )
         | 
| 21 21 | 
             
              end
         | 
| 22 22 | 
             
              #Is raised when an error is found in a specification
         | 
| @@ -167,7 +167,7 @@ module Rutema | |
| 167 167 | 
             
                def parse_specification param
         | 
| 168 168 | 
             
                  spec = super(param)
         | 
| 169 169 | 
             
                  #change into the directory the spec is in to handle relative paths correctly
         | 
| 170 | 
            -
                  Dir.chdir(File.dirname(spec.filename)) do |path|
         | 
| 170 | 
            +
                  Dir.chdir(File.dirname(File.expand_path(spec.filename))) do |path|
         | 
| 171 171 | 
             
                    spec.scenario.steps.each do |step|
         | 
| 172 172 | 
             
                      case step.step_type
         | 
| 173 173 | 
             
                      when "echo"
         | 
| @@ -241,11 +241,13 @@ module Rutema | |
| 241 241 | 
             
                      @logger.debug("Running #{spec}")
         | 
| 242 242 | 
             
                      run_test(spec) if spec
         | 
| 243 243 | 
             
                    else
         | 
| 244 | 
            -
                      @logger. | 
| 244 | 
            +
                      @logger.fatal("Don't know how to run '#{mode}'")
         | 
| 245 | 
            +
                      exit 1
         | 
| 245 246 | 
             
                    end
         | 
| 246 247 | 
             
                  rescue
         | 
| 247 248 | 
             
                    @logger.debug($!)
         | 
| 248 | 
            -
                    @logger. | 
| 249 | 
            +
                    @logger.fatal("Runner error: #{$!.message}")
         | 
| 250 | 
            +
                    exit 1
         | 
| 249 251 | 
             
                  end
         | 
| 250 252 | 
             
                  @configuration.context.end_time=Time.now
         | 
| 251 253 | 
             
                  @logger.info("Run completed in #{@configuration.context.end_time-@configuration.context.start_time}s")
         | 
| @@ -267,7 +269,11 @@ module Rutema | |
| 267 269 | 
             
                    t.join
         | 
| 268 270 | 
             
                  end
         | 
| 269 271 | 
             
                end
         | 
| 270 | 
            -
             | 
| 272 | 
            +
                
         | 
| 273 | 
            +
                #returns true if all scenarios in the last run were succesful
         | 
| 274 | 
            +
                def last_run_a_success?
         | 
| 275 | 
            +
                  return @runner.success?
         | 
| 276 | 
            +
                end
         | 
| 271 277 | 
             
                def to_s
         | 
| 272 278 | 
             
                  "Parsed #{@parsed_files.size} files\n#{Rutema.text_report(@runner.states.values,@parse_errors)}"
         | 
| 273 279 | 
             
                end
         | 
| @@ -416,6 +422,15 @@ module Rutema | |
| 416 422 | 
             
                  @states.clear
         | 
| 417 423 | 
             
                  @number_of_runs=0
         | 
| 418 424 | 
             
                end
         | 
| 425 | 
            +
                
         | 
| 426 | 
            +
                #returns true if all the scenarios in the last run were succesfull or if nothing was run yet
         | 
| 427 | 
            +
                def success?
         | 
| 428 | 
            +
                  @success=true
         | 
| 429 | 
            +
                  @states.each  do |k,v|
         | 
| 430 | 
            +
                    @success&=v.success?
         | 
| 431 | 
            +
                  end
         | 
| 432 | 
            +
                  return @success
         | 
| 433 | 
            +
                end
         | 
| 419 434 | 
             
                private
         | 
| 420 435 | 
             
                def run_scenario name,scenario
         | 
| 421 436 | 
             
                  state=Patir::CommandSequenceStatus.new(name,scenario.steps)
         | 
| @@ -555,7 +570,8 @@ module Rutema | |
| 555 570 | 
             
                    if @configuration.check
         | 
| 556 571 | 
             
                      @coordinator.run(@configuration.check)
         | 
| 557 572 | 
             
                    else
         | 
| 558 | 
            -
                      @logger. | 
| 573 | 
            +
                      @logger.fatal("There is no check test defined in the configuration.")
         | 
| 574 | 
            +
                      exit 1
         | 
| 559 575 | 
             
                    end
         | 
| 560 576 | 
             
                  else
         | 
| 561 577 | 
             
                    #run everything
         | 
| @@ -563,6 +579,12 @@ module Rutema | |
| 563 579 | 
             
                  end
         | 
| 564 580 | 
             
                  @logger.info("Report:\n#{@coordinator.to_s}")
         | 
| 565 581 | 
             
                  @coordinator.report
         | 
| 582 | 
            +
                  if @coordinator.parse_errors.empty? && @coordinator.last_run_a_success?
         | 
| 583 | 
            +
                    exit 0
         | 
| 584 | 
            +
                  else
         | 
| 585 | 
            +
                    @logger.warn("Not all tests were succesfull")
         | 
| 586 | 
            +
                    exit 1
         | 
| 587 | 
            +
                  end
         | 
| 566 588 | 
             
                end
         | 
| 567 589 | 
             
              end
         | 
| 568 590 |  | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -13,11 +13,11 @@ table { | |
| 13 13 | 
             
            	text-align: center;
         | 
| 14 14 |  | 
| 15 15 | 
             
            }
         | 
| 16 | 
            -
            #logo{float:left; background-image:url(tie_logo.gif); width:234px; height:213px;}
         | 
| 16 | 
            +
            #logo{float:left; background-image:url(/tie_logo.gif); width:234px; height:213px;}
         | 
| 17 17 | 
             
            #topheader{float:right; width:566px; height:97px; background-color:#F0F0F0; position:relative}
         | 
| 18 18 | 
             
            #toplinks{position:absolute; right:10px; top:10px;}
         | 
| 19 | 
            -
            #menu{float:right; width:566px; height:32px; background-image:url(bg_menu.gif); background-repeat:repeat-x;}
         | 
| 20 | 
            -
            #submenu{float:right; width:566px; height:32px; background-image:url(bg_submenu.gif); background-position:top; background-repeat:repeat-x;}
         | 
| 19 | 
            +
            #menu{float:right; width:566px; height:32px; background-image:url(/bg_menu.gif); background-repeat:repeat-x;}
         | 
| 20 | 
            +
            #submenu{float:right; width:566px; height:32px; background-image:url(/bg_submenu.gif); background-position:top; background-repeat:repeat-x;}
         | 
| 21 21 | 
             
            #contenttext{float:right; width:566px;}
         | 
| 22 22 | 
             
            #contentnopanel{float:left; width:800px}
         | 
| 23 23 | 
             
            #leftpanel{float:left; width:234px;}
         | 
| 
            File without changes
         | 
| @@ -0,0 +1,164 @@ | |
| 1 | 
            +
            #  Copyright (c) 2008 Vassilis Rizopoulos. All rights reserved.
         | 
| 2 | 
            +
            $:.unshift File.join(File.dirname(__FILE__),"..")
         | 
| 3 | 
            +
            require 'rutema/system'
         | 
| 4 | 
            +
            require 'rubygems'
         | 
| 5 | 
            +
            require 'ramaze'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Rutema
         | 
| 8 | 
            +
              module UI
         | 
| 9 | 
            +
                class MainController < Ramaze::Controller
         | 
| 10 | 
            +
                  engine :Erubis
         | 
| 11 | 
            +
                  layout :layout
         | 
| 12 | 
            +
                  #Time format to use for the start and stop times
         | 
| 13 | 
            +
                  TIME_FORMAT="%y%m%d - %H:%M:%S"
         | 
| 14 | 
            +
                  #image filename to use for succesfull scenarios
         | 
| 15 | 
            +
                  IMG_SCE_OK="/run_ok.png"
         | 
| 16 | 
            +
                  #image filename to use for failed scenarios
         | 
| 17 | 
            +
                  IMG_SCE_ERROR="/run_error.png"
         | 
| 18 | 
            +
                  #image filename to use for unexecuted scenarios
         | 
| 19 | 
            +
                  IMG_SCE_WARN="/run_warn.png"
         | 
| 20 | 
            +
                  #image filename to use for succesfull steps
         | 
| 21 | 
            +
                  IMG_STEP_OK="/step_ok.png"
         | 
| 22 | 
            +
                  #image filename to use for failed steps
         | 
| 23 | 
            +
                  IMG_STEP_ERROR="/step_error.png"
         | 
| 24 | 
            +
                  #image filename to use for unexecuted steps
         | 
| 25 | 
            +
                  IMG_STEP_WARN="/step_warn.png"
         | 
| 26 | 
            +
                  def index
         | 
| 27 | 
            +
                    @panel_content=panel_content(:runs)
         | 
| 28 | 
            +
                    @content="<p>This is the rutema web interface.<br/>It allows you to browse the contents of the test results database.</p><p>Currently you can view the results for each separate run, the results for a specific scenario (a complete list of all steps executed in the scenario with standard and error output logs) or the complete execution history of a scenario.</p>"
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                  def run run_id=""
         | 
| 31 | 
            +
                    @panel_content=panel_content(:runs)
         | 
| 32 | 
            +
                    if !run_id.empty?
         | 
| 33 | 
            +
                      @content=single_run(run_id)
         | 
| 34 | 
            +
                    end
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                  def scenario scenario_id=""
         | 
| 37 | 
            +
                    @panel_content=panel_content(:scenarios)
         | 
| 38 | 
            +
                    if !scenario_id.empty?
         | 
| 39 | 
            +
                      if scenario_id.to_i==0
         | 
| 40 | 
            +
                        @content=scenario_by_name(scenario_id)
         | 
| 41 | 
            +
                      else
         | 
| 42 | 
            +
                        @content=scenario_in_a_run(scenario_id)
         | 
| 43 | 
            +
                      end
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
                  private 
         | 
| 47 | 
            +
                  #Renders the summary of all runs for a single scenario
         | 
| 48 | 
            +
                  def scenario_by_name scenario_id
         | 
| 49 | 
            +
                    ret=""
         | 
| 50 | 
            +
                    begin
         | 
| 51 | 
            +
                      table=Rutema::Model::Scenario.report_table(:all,:conditions=>["name = :spec_name",{:spec_name=>scenario_id}])
         | 
| 52 | 
            +
                      if table.empty?
         | 
| 53 | 
            +
                        ret="<p>no results for #{scenario_id}</p>"
         | 
| 54 | 
            +
                      else
         | 
| 55 | 
            +
                        table.replace_column("status") do |r| 
         | 
| 56 | 
            +
                          scenario_status_snippet(r)
         | 
| 57 | 
            +
                        end
         | 
| 58 | 
            +
                        table.replace_column("version") {|r| r.version ? r.version : "N/A"}
         | 
| 59 | 
            +
                        table.replace_column("start_time"){|r| r.stop_time ? r.start_time.strftime(TIME_FORMAT) : nil}
         | 
| 60 | 
            +
                        table.replace_column("stop_time"){|r| r.stop_time.strftime(TIME_FORMAT)}
         | 
| 61 | 
            +
                        table.reorder("status","run_id","version","start_time","stop_time")
         | 
| 62 | 
            +
                        ret<<table.to_html
         | 
| 63 | 
            +
                      end
         | 
| 64 | 
            +
                    rescue
         | 
| 65 | 
            +
                      puts $!
         | 
| 66 | 
            +
                      "<p>could not retrieve data for #{scenario_id}</p>"
         | 
| 67 | 
            +
                    end
         | 
| 68 | 
            +
                    return ret
         | 
| 69 | 
            +
                  end
         | 
| 70 | 
            +
                  #Renders the information for a specific executed scenario
         | 
| 71 | 
            +
                  #giving a detailed list of the steps, with status and output
         | 
| 72 | 
            +
                  def scenario_in_a_run scenario_id
         | 
| 73 | 
            +
                    table=Rutema::Model::Step.report_table(:all,:conditions=>["scenario_id = :scenario_id",{:scenario_id=>scenario_id}])
         | 
| 74 | 
            +
                    if table.empty?
         | 
| 75 | 
            +
                      ret="<p>no results for #{scenario_id}</p>"
         | 
| 76 | 
            +
                    else
         | 
| 77 | 
            +
                      table.replace_column("status") do |r| 
         | 
| 78 | 
            +
                        img_src=IMG_STEP_WARN if "not_executed"==r.status
         | 
| 79 | 
            +
                        img_src=IMG_STEP_OK if "success"==r.status
         | 
| 80 | 
            +
                        img_src=IMG_STEP_ERROR if "error"==r.status
         | 
| 81 | 
            +
                        "<img src=\"#{img_src}\" align=\"center\"/>"
         | 
| 82 | 
            +
                      end
         | 
| 83 | 
            +
                      table.reorder("number","status","name","output","error","duration")
         | 
| 84 | 
            +
                      ret=table.to_html
         | 
| 85 | 
            +
                    end
         | 
| 86 | 
            +
                    return ret
         | 
| 87 | 
            +
                  end
         | 
| 88 | 
            +
                  #will render a hash in a table of key||value rows 
         | 
| 89 | 
            +
                  def context_table context
         | 
| 90 | 
            +
                    ret="<table><tr>"
         | 
| 91 | 
            +
                    context.each do |k,v|
         | 
| 92 | 
            +
                      ret<<"<td>#{k.to_s}</td><td>#{v.to_s}</td>"
         | 
| 93 | 
            +
                    end
         | 
| 94 | 
            +
                    ret<<"</tr></table>"
         | 
| 95 | 
            +
                  end
         | 
| 96 | 
            +
                  #Renders the information for a single run providing the context and a list of the scenarios
         | 
| 97 | 
            +
                  def single_run run_id
         | 
| 98 | 
            +
                    ret=""
         | 
| 99 | 
            +
                    begin
         | 
| 100 | 
            +
                      run=Rutema::Model::Run.find(run_id)
         | 
| 101 | 
            +
                    rescue
         | 
| 102 | 
            +
                      return "Could not find #{run_id}"
         | 
| 103 | 
            +
                    end
         | 
| 104 | 
            +
                    if run.context
         | 
| 105 | 
            +
                      ret<<context_table(run.context)
         | 
| 106 | 
            +
                    end
         | 
| 107 | 
            +
                    table=Rutema::Model::Scenario.report_table(:all,:conditions=>["run_id = :run_id",{:run_id=>run_id}],:except=>["run_id"])
         | 
| 108 | 
            +
                    if table.empty?
         | 
| 109 | 
            +
                      return "No scenarios for run #{run_id}"
         | 
| 110 | 
            +
                    else
         | 
| 111 | 
            +
                      table.replace_column("status") do |r| 
         | 
| 112 | 
            +
                        scenario_status_snippet(r)
         | 
| 113 | 
            +
                      end
         | 
| 114 | 
            +
                      table.replace_column("version") {|r| r.version ? r.version : "N/A"}
         | 
| 115 | 
            +
                      table.replace_column("start_time"){|r| r.stop_time ? r.start_time.strftime(TIME_FORMAT) : nil}
         | 
| 116 | 
            +
                      table.replace_column("stop_time"){|r| r.stop_time.strftime(TIME_FORMAT)}
         | 
| 117 | 
            +
                      table.reorder("status","name","version","start_time","stop_time")
         | 
| 118 | 
            +
                      ret<<table.to_html
         | 
| 119 | 
            +
                    end
         | 
| 120 | 
            +
                    return ret
         | 
| 121 | 
            +
                  end
         | 
| 122 | 
            +
                  #Gives the HTML to use for the status column of a scenario list
         | 
| 123 | 
            +
                  def scenario_status_snippet r
         | 
| 124 | 
            +
                    if "not_executed"==r.status
         | 
| 125 | 
            +
                      "<img src=\"#{IMG_SCE_WARN}\"  align=\"center\"/>"
         | 
| 126 | 
            +
                    else
         | 
| 127 | 
            +
                      img_src=IMG_SCE_OK if "success"==r.status
         | 
| 128 | 
            +
                      img_src=IMG_SCE_ERROR if "error"==r.status
         | 
| 129 | 
            +
                      "<a href=\"/scenario/#{r.data["id"]}\"><img src=\"#{img_src}\" align=\"center\"/></a>"
         | 
| 130 | 
            +
                    end
         | 
| 131 | 
            +
                  end
         | 
| 132 | 
            +
                  def panel_content context
         | 
| 133 | 
            +
                    ret=""
         | 
| 134 | 
            +
                    if context==:runs
         | 
| 135 | 
            +
                      #<img src="run_error.png" align="center"/><a href="index.html" class="smallgraytext">1 - 28.06.2007</a>
         | 
| 136 | 
            +
                      Rutema::Model::Run.find(:all,:select=>"id").reverse.each do |r|
         | 
| 137 | 
            +
                        ret<<"<a class=\"smallgreytext\" href=\"/run/#{r.id}\">Run #{r.id}</a><br/>"
         | 
| 138 | 
            +
                      end
         | 
| 139 | 
            +
                    elsif context==:scenarios
         | 
| 140 | 
            +
                      result=Rutema::Model::Scenario.find(:all).collect{|r| r.name}
         | 
| 141 | 
            +
                      result.uniq.sort.each do |r|
         | 
| 142 | 
            +
                        ret<<"<a class=\"smallgreytext\" href=\"/scenario/#{r}\">#{r}</a><br/>"
         | 
| 143 | 
            +
                      end
         | 
| 144 | 
            +
                    end
         | 
| 145 | 
            +
                    return ret
         | 
| 146 | 
            +
                  end
         | 
| 147 | 
            +
                end
         | 
| 148 | 
            +
              end
         | 
| 149 | 
            +
            end
         | 
| 150 | 
            +
            def start_ramaze
         | 
| 151 | 
            +
              dbfile=ARGV.shift
         | 
| 152 | 
            +
              if !dbfile
         | 
| 153 | 
            +
                puts "please provide a database filename"
         | 
| 154 | 
            +
                exit 0
         | 
| 155 | 
            +
              end
         | 
| 156 | 
            +
              if File.exist?(dbfile)
         | 
| 157 | 
            +
                ActiveRecord::Base.establish_connection(:adapter=>"sqlite3", :database=>File.expand_path(dbfile) )
         | 
| 158 | 
            +
                Dir.chdir(File.dirname(__FILE__)) do
         | 
| 159 | 
            +
                  Ramaze.start :force=>true#,:adapter=>:thin
         | 
| 160 | 
            +
                end
         | 
| 161 | 
            +
              else
         | 
| 162 | 
            +
                $stderr.puts "Can't find database file '#{dbfile}'"
         | 
| 163 | 
            +
              end
         | 
| 164 | 
            +
            end
         | 
| @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
         | 
| 2 | 
            +
            <html xmlns="http://www.w3.org/1999/xhtml">
         | 
| 3 | 
            +
            <head>
         | 
| 4 | 
            +
            	<meta name="author" content="Vassilis Rizopoulos" />
         | 
| 5 | 
            +
            	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
         | 
| 6 | 
            +
            	<link rel="stylesheet" href="/style.css" type="text/css" />
         | 
| 7 | 
            +
            	<title>Rutema Historian</title>
         | 
| 8 | 
            +
            </head>
         | 
| 9 | 
            +
            <body>
         | 
| 10 | 
            +
            	<div id="page" align="center">
         | 
| 11 | 
            +
            		<div id="content" style="width:800px">
         | 
| 12 | 
            +
            			<div id="logo">
         | 
| 13 | 
            +
            				<div style="margin-top:70px" class="whitetitle">rutema</div>
         | 
| 14 | 
            +
            			</div>
         | 
| 15 | 
            +
            			<div id="topheader">
         | 
| 16 | 
            +
            				<div align="left" class="bodytext">
         | 
| 17 | 
            +
            				</div>
         | 
| 18 | 
            +
            				<div id="toplinks" class="smallgraytext">
         | 
| 19 | 
            +
            				</div>
         | 
| 20 | 
            +
            			</div>
         | 
| 21 | 
            +
            			<div id="menu">
         | 
| 22 | 
            +
            				<div align="right" class="smallwhitetext" style="padding:9px;">
         | 
| 23 | 
            +
            					<a href="/">Home</a> | <a href="/run">Runs</a> | <a href="/scenario">Scenarios</a>
         | 
| 24 | 
            +
            				</div>
         | 
| 25 | 
            +
            			</div>
         | 
| 26 | 
            +
            			<div id="submenu">
         | 
| 27 | 
            +
            				<div align="right" class="smallgraytext" style="padding:9px;"></div>
         | 
| 28 | 
            +
            			</div>
         | 
| 29 | 
            +
            			<div id="contenttext">
         | 
| 30 | 
            +
            				<div style="padding:10px">
         | 
| 31 | 
            +
            					<span class="titletext">Summary</span>
         | 
| 32 | 
            +
            				</div>
         | 
| 33 | 
            +
            				<div class="bodytext" style="padding:12px;" align="justify"><%=@content%></div>
         | 
| 34 | 
            +
            			</div>
         | 
| 35 | 
            +
            			<div id="leftpanel">
         | 
| 36 | 
            +
            				<div align="justify" class="graypanel">
         | 
| 37 | 
            +
            					<%=@panel_content%>
         | 
| 38 | 
            +
            				</div>
         | 
| 39 | 
            +
            			</div>
         | 
| 40 | 
            +
            			<div id="footer" class="smallgraytext">
         | 
| 41 | 
            +
            				<a href="/">Home</a> | <a href="http://patir.rubyforge.org/rutema">about rutema</a> | 
         | 
| 42 | 
            +
            				© 2008 <a href="http://www.braveworld.net/riva" target="_blank">Vassilis Rizopoulos</a> 
         | 
| 43 | 
            +
            			</div>
         | 
| 44 | 
            +
            		</div>
         | 
| 45 | 
            +
            	</div>
         | 
| 46 | 
            +
            </body>
         | 
| 47 | 
            +
            </html>
         | 
    
        data/test/rutema.rutema
    ADDED
    
    
    
        data/test/rutema.spec
    ADDED
    
    | @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            <specification name="TR001">
         | 
| 2 | 
            +
            <title>Rutema self hosting test</title>
         | 
| 3 | 
            +
            <description>Test that rutemax and rutemah are usable as steps in a specification using the distro test example</description>
         | 
| 4 | 
            +
            <scenario>
         | 
| 5 | 
            +
            	<command cmd="rutemax -c distro_test/config/minimal.rutema"/>
         | 
| 6 | 
            +
            	<command cmd="rutemax -c distro_test/config/database.rutema"/>
         | 
| 7 | 
            +
            	<command cmd="rutemah -c distro_test/config/database.rutemah all"/>
         | 
| 8 | 
            +
            </scenario>
         | 
| 9 | 
            +
            </specification>
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: rutema
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.5.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Vassilis Rizopoulos
         | 
| @@ -9,7 +9,7 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date: 2008-02- | 
| 12 | 
            +
            date: 2008-02-26 00:00:00 +01:00
         | 
| 13 13 | 
             
            default_executable: rutemax
         | 
| 14 14 | 
             
            dependencies: 
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -19,7 +19,7 @@ dependencies: | |
| 19 19 | 
             
                requirements: 
         | 
| 20 20 | 
             
                - - ">="
         | 
| 21 21 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 22 | 
            -
                    version:  | 
| 22 | 
            +
                    version: 0.5.2
         | 
| 23 23 | 
             
                version: 
         | 
| 24 24 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 25 25 | 
             
              name: highline
         | 
| @@ -67,7 +67,16 @@ dependencies: | |
| 67 67 | 
             
                    version: "0"
         | 
| 68 68 | 
             
                version: 
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 70 | 
            -
              name:  | 
| 70 | 
            +
              name: ramaze
         | 
| 71 | 
            +
              version_requirement: 
         | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 73 | 
            +
                requirements: 
         | 
| 74 | 
            +
                - - ">="
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 76 | 
            +
                    version: "0"
         | 
| 77 | 
            +
                version: 
         | 
| 78 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 79 | 
            +
              name: erubis
         | 
| 71 80 | 
             
              version_requirement: 
         | 
| 72 81 | 
             
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 73 82 | 
             
                requirements: 
         | 
| @@ -113,22 +122,25 @@ files: | |
| 113 122 | 
             
            - lib/rutema/reporter_ar.rb
         | 
| 114 123 | 
             
            - lib/rutema/historian.rb
         | 
| 115 124 | 
             
            - lib/rutema/model.rb
         | 
| 116 | 
            -
            - lib/rutemaweb/ | 
| 117 | 
            -
            - lib/rutemaweb/ | 
| 118 | 
            -
            - lib/rutemaweb/ | 
| 119 | 
            -
            - lib/rutemaweb/ | 
| 120 | 
            -
            - lib/rutemaweb/ | 
| 121 | 
            -
            - lib/rutemaweb/ | 
| 122 | 
            -
            - lib/rutemaweb/ | 
| 123 | 
            -
            - lib/rutemaweb/ | 
| 124 | 
            -
            - lib/rutemaweb/ | 
| 125 | 
            -
            - lib/rutemaweb/ | 
| 126 | 
            -
            - lib/rutemaweb/ | 
| 125 | 
            +
            - lib/rutemaweb/ramaze_controller.rb
         | 
| 126 | 
            +
            - lib/rutemaweb/public/bg_menu.gif
         | 
| 127 | 
            +
            - lib/rutemaweb/public/bg_submenu.gif
         | 
| 128 | 
            +
            - lib/rutemaweb/public/run_error.png
         | 
| 129 | 
            +
            - lib/rutemaweb/public/run_ok.png
         | 
| 130 | 
            +
            - lib/rutemaweb/public/run_warn.png
         | 
| 131 | 
            +
            - lib/rutemaweb/public/step_error.png
         | 
| 132 | 
            +
            - lib/rutemaweb/public/step_ok.png
         | 
| 133 | 
            +
            - lib/rutemaweb/public/step_warn.png
         | 
| 134 | 
            +
            - lib/rutemaweb/public/style.css
         | 
| 135 | 
            +
            - lib/rutemaweb/public/tie_logo.gif
         | 
| 136 | 
            +
            - lib/rutemaweb/view/layout.rhtml
         | 
| 127 137 | 
             
            - test/test_configuration.rb
         | 
| 128 138 | 
             
            - test/test_specification.rb
         | 
| 129 139 | 
             
            - test/test_system.rb
         | 
| 130 140 | 
             
            - test/test_historian.rb
         | 
| 131 141 | 
             
            - test/test_reporter.rb
         | 
| 142 | 
            +
            - test/rutema.rutema
         | 
| 143 | 
            +
            - test/rutema.spec
         | 
| 132 144 | 
             
            - test/samples/check.spec
         | 
| 133 145 | 
             
            - test/samples/setup.spec
         | 
| 134 146 | 
             
            - test/samples/teardown.spec
         | 
    
        data/lib/rutemaweb/rutemaweb.rb
    DELETED
    
    | @@ -1,245 +0,0 @@ | |
| 1 | 
            -
            #  Copyright (c) 2007 Vassilis Rizopoulos. All rights reserved.
         | 
| 2 | 
            -
            $:.unshift File.join(File.dirname(__FILE__),"..")
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            require 'rutema/model'
         | 
| 5 | 
            -
            require 'rutema/historian'
         | 
| 6 | 
            -
            require 'webrick'
         | 
| 7 | 
            -
            require 'rubygems'
         | 
| 8 | 
            -
            require 'camping/webrick'
         | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
            Camping.goes :RutemaWeb
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            #This is the module containing the Camping views and controllers for the web interface to rutema
         | 
| 14 | 
            -
            module RutemaWeb
         | 
| 15 | 
            -
              HTDOCS=File.expand_path(File.join(File.dirname(__FILE__),"htdocs"))
         | 
| 16 | 
            -
              #The rutema web interface controllers
         | 
| 17 | 
            -
              module RutemaWeb::Controllers
         | 
| 18 | 
            -
                #This is the main controller
         | 
| 19 | 
            -
                #
         | 
| 20 | 
            -
                #The various views on the data are found through the query keys
         | 
| 21 | 
            -
                class Index < R '/'
         | 
| 22 | 
            -
                  def get
         | 
| 23 | 
            -
                    @head_title||="Rutema Historian"
         | 
| 24 | 
            -
                    @white_title||="Runs"
         | 
| 25 | 
            -
                    @title||="History"
         | 
| 26 | 
            -
                    @left_panel=:runs
         | 
| 27 | 
            -
                    if @input.empty?
         | 
| 28 | 
            -
                      render :start
         | 
| 29 | 
            -
                    else
         | 
| 30 | 
            -
                      if @input["scenario"]
         | 
| 31 | 
            -
                        @scenario_id=@input[:scenario]
         | 
| 32 | 
            -
                        scenario=Rutema::Model::Scenario.find(@scenario_id)
         | 
| 33 | 
            -
                        @title="#{scenario.name} from Run ##{scenario.run_id}"
         | 
| 34 | 
            -
                        @white_title="Scenario <br/>##{@scenario_id}"
         | 
| 35 | 
            -
                        render :scenario_in_a_run
         | 
| 36 | 
            -
                      elsif @input[:run]
         | 
| 37 | 
            -
                        @run_id=@input[:run]
         | 
| 38 | 
            -
                        @white_title="Run ##{@run_id}"
         | 
| 39 | 
            -
                        @title="Summary"
         | 
| 40 | 
            -
                        render :single_run
         | 
| 41 | 
            -
                      elsif @input["scenario_name"]
         | 
| 42 | 
            -
                        @spec_name=@input["scenario_name"]
         | 
| 43 | 
            -
                        @white_title=@spec_name
         | 
| 44 | 
            -
                        @title="Summary"
         | 
| 45 | 
            -
                        render :scenario_by_name
         | 
| 46 | 
            -
                      elsif @input["scenarios"]
         | 
| 47 | 
            -
                        @white_title="Scenarios"
         | 
| 48 | 
            -
                        @title="Summary"
         | 
| 49 | 
            -
                        @left_panel=:scenarios
         | 
| 50 | 
            -
                        render :start
         | 
| 51 | 
            -
                      elsif @input["runs"]
         | 
| 52 | 
            -
                        @white_title="Runs"
         | 
| 53 | 
            -
                        @title="Summary"
         | 
| 54 | 
            -
                        @left_panel=:runs
         | 
| 55 | 
            -
                        render :start
         | 
| 56 | 
            -
                      end
         | 
| 57 | 
            -
                    end
         | 
| 58 | 
            -
                  end
         | 
| 59 | 
            -
                end
         | 
| 60 | 
            -
                
         | 
| 61 | 
            -
                class StyleSheetsAndImages < R '/(.*[css|jpg|png|gif])'
         | 
| 62 | 
            -
                  def get name
         | 
| 63 | 
            -
                    @headers['Content-Type'] = "image/jpg" if name=~/$jpg/
         | 
| 64 | 
            -
                    @headers['Content-Type'] = "image/png" if name=~/$png/
         | 
| 65 | 
            -
                    @headers['Content-Type'] = "image/gif" if name=~/$gif/
         | 
| 66 | 
            -
                    @headers['Content-Type'] = "text/css" if name=~/$css/
         | 
| 67 | 
            -
                    @headers['X-Sendfile'] = File.join(RutemaWeb::HTDOCS,name)
         | 
| 68 | 
            -
                  end
         | 
| 69 | 
            -
                end
         | 
| 70 | 
            -
              end
         | 
| 71 | 
            -
              module RutemaWeb::Views
         | 
| 72 | 
            -
                #Time format to use for the start and stop times
         | 
| 73 | 
            -
                TIME_FORMAT="%y%m%d - %H:%M:%S"
         | 
| 74 | 
            -
                #image filename to use for succesfull scenarios
         | 
| 75 | 
            -
                IMG_SCE_OK="run_ok.png"
         | 
| 76 | 
            -
                #image filename to use for failed scenarios
         | 
| 77 | 
            -
                IMG_SCE_ERROR="run_error.png"
         | 
| 78 | 
            -
                #image filename to use for unexecuted scenarios
         | 
| 79 | 
            -
                IMG_SCE_WARN="run_warn.png"
         | 
| 80 | 
            -
                #image filename to use for succesfull steps
         | 
| 81 | 
            -
                IMG_STEP_OK="step_ok.png"
         | 
| 82 | 
            -
                #image filename to use for failed steps
         | 
| 83 | 
            -
                IMG_STEP_ERROR="step_error.png"
         | 
| 84 | 
            -
                #image filename to use for unexecuted steps
         | 
| 85 | 
            -
                IMG_STEP_WARN="step_warn.png"
         | 
| 86 | 
            -
                #The whole page in Markaby
         | 
| 87 | 
            -
                def layout
         | 
| 88 | 
            -
                  xhtml_transitional do
         | 
| 89 | 
            -
                    head do
         | 
| 90 | 
            -
                      meta(:name=>"author",:content=>"Vassilis Rizopoulos")
         | 
| 91 | 
            -
                      link(:rel=>"stylesheet",:href=>"style.css",:type=>"text/css")
         | 
| 92 | 
            -
                      title { @head_title }
         | 
| 93 | 
            -
                    end
         | 
| 94 | 
            -
                    body do 
         | 
| 95 | 
            -
                      div.page!(:align=>"center") do
         | 
| 96 | 
            -
                        div.content!(:style=>"width:800px") do
         | 
| 97 | 
            -
                          div.logo!{div.whitetitle(:style=>"margin-top:70px"){@white_title}}
         | 
| 98 | 
            -
                          div.topheader!{div.bodytext(:align=>"left"){br} }
         | 
| 99 | 
            -
                          div.menu!{}
         | 
| 100 | 
            -
                          div.submenu! do
         | 
| 101 | 
            -
                            div(:align=>"right",:class=>"smallgraytext",:style=>"padding:9px;") do
         | 
| 102 | 
            -
                              a(:href=>"?runs=all"){"runs"}+" | "+a(:href=>"?scenarios=all"){"scenarios"}
         | 
| 103 | 
            -
                            end
         | 
| 104 | 
            -
                          end
         | 
| 105 | 
            -
                          div.contenttext! do
         | 
| 106 | 
            -
                            div(:style=>"padding:10px"){span.titletext{@title}}
         | 
| 107 | 
            -
                            div.bodytext(:style=>"padding:12px;", :align=>"justify"){self<<yield}
         | 
| 108 | 
            -
                          end
         | 
| 109 | 
            -
                          leftpanel
         | 
| 110 | 
            -
                          div.footer!(:class=>"smallgraytext") {"© 2007 Vassilis Rizopoulos"}
         | 
| 111 | 
            -
                        end
         | 
| 112 | 
            -
                      end 
         | 
| 113 | 
            -
                    end
         | 
| 114 | 
            -
                  end
         | 
| 115 | 
            -
                end
         | 
| 116 | 
            -
                
         | 
| 117 | 
            -
                #Start point: No rendering content
         | 
| 118 | 
            -
                def start
         | 
| 119 | 
            -
                  	p{"This is the rutema web interface.<br/>It allows you to browse the contents of the test results database."}
         | 
| 120 | 
            -
            				p{"Currently you can view the results for each separate run, the results for a specific scenario (a complete list of all steps executed in the scenario with standard and error output logs) or the complete execution history of a scenario."}
         | 
| 121 | 
            -
                end
         | 
| 122 | 
            -
                
         | 
| 123 | 
            -
                #Renders the information for a specific executed scenario
         | 
| 124 | 
            -
                #giving a detailed list of the steps, with status and output
         | 
| 125 | 
            -
                def scenario_in_a_run
         | 
| 126 | 
            -
                  table=Rutema::Model::Step.report_table(:all,:conditions=>["scenario_id = :scenario_id",{:scenario_id=>@scenario_id}])
         | 
| 127 | 
            -
                  table.replace_column("status") do |r| 
         | 
| 128 | 
            -
                    img_src=IMG_STEP_WARN if "not_executed"==r.status
         | 
| 129 | 
            -
                    img_src=IMG_STEP_OK if "success"==r.status
         | 
| 130 | 
            -
                    img_src=IMG_STEP_ERROR if "error"==r.status
         | 
| 131 | 
            -
                    img(:src=>img_src,:align=>"center")
         | 
| 132 | 
            -
                  end
         | 
| 133 | 
            -
                  table.reorder("number","status","name","output","error","duration")
         | 
| 134 | 
            -
                  table.to_html
         | 
| 135 | 
            -
                end
         | 
| 136 | 
            -
                #Renders the information for a single run providing the context and a list of the scenarios
         | 
| 137 | 
            -
                def single_run
         | 
| 138 | 
            -
                  ret=""
         | 
| 139 | 
            -
                  run=Rutema::Model::Run.find(@run_id)
         | 
| 140 | 
            -
                  if run.context
         | 
| 141 | 
            -
                   ret<<context_table(run.context)
         | 
| 142 | 
            -
                  end
         | 
| 143 | 
            -
                  table=Rutema::Model::Scenario.report_table(:all,:conditions=>["run_id = :run_id",{:run_id=>@run_id}],:except=>["run_id"])
         | 
| 144 | 
            -
                  table.replace_column("status") do |r| 
         | 
| 145 | 
            -
                    if "not_executed"==r.status
         | 
| 146 | 
            -
                      img(:src=>IMG_SCE_WARN,:align=>"center")
         | 
| 147 | 
            -
                    else
         | 
| 148 | 
            -
                      img_src=IMG_SCE_OK if "success"==r.status
         | 
| 149 | 
            -
                      img_src=IMG_SCE_ERROR if "error"==r.status
         | 
| 150 | 
            -
                      a(:href=> "?scenario=#{r.data["id"]}"){img(:src=>img_src,:align=>"center")}
         | 
| 151 | 
            -
                    end
         | 
| 152 | 
            -
                  end
         | 
| 153 | 
            -
                  table.replace_column("version") {|r| r.version ? r.version : "N/A"}
         | 
| 154 | 
            -
                  table.replace_column("start_time"){|r| r.stop_time ? r.start_time.strftime(TIME_FORMAT) : nil}
         | 
| 155 | 
            -
                  table.replace_column("stop_time"){|r| r.stop_time.strftime(TIME_FORMAT)}
         | 
| 156 | 
            -
                  table.reorder("status","name","version","start_time","stop_time")
         | 
| 157 | 
            -
                  ret<<table.to_html
         | 
| 158 | 
            -
                  return ret
         | 
| 159 | 
            -
                end
         | 
| 160 | 
            -
                
         | 
| 161 | 
            -
                #Renders the summary of all runs for a single scenario
         | 
| 162 | 
            -
                def scenario_by_name
         | 
| 163 | 
            -
                  ret=""
         | 
| 164 | 
            -
                  begin
         | 
| 165 | 
            -
                    table=Rutema::Model::Scenario.report_table(:all,:conditions=>["name = :spec_name",{:spec_name=>@spec_name}])
         | 
| 166 | 
            -
                    if table.empty?
         | 
| 167 | 
            -
                      ret=p{"no results for #{@spec_name}"}
         | 
| 168 | 
            -
                    else
         | 
| 169 | 
            -
                      table.replace_column("status") do |r| 
         | 
| 170 | 
            -
                        if "not_executed"==r.status
         | 
| 171 | 
            -
                          img(:src=>IMG_SCE_WARN,:align=>"center")
         | 
| 172 | 
            -
                        else
         | 
| 173 | 
            -
                          img_src=IMG_SCE_OK if "success"==r.status
         | 
| 174 | 
            -
                          img_src=IMG_SCE_ERROR if "error"==r.status
         | 
| 175 | 
            -
                          a(:href=> "?scenario=#{r.data["id"]}"){img(:src=>img_src,:align=>"center")}
         | 
| 176 | 
            -
                        end
         | 
| 177 | 
            -
                      end
         | 
| 178 | 
            -
                      table.replace_column("version") {|r| r.version ? r.version : "N/A"}
         | 
| 179 | 
            -
                      table.replace_column("start_time"){|r| r.stop_time ? r.start_time.strftime(TIME_FORMAT) : nil}
         | 
| 180 | 
            -
                      table.replace_column("stop_time"){|r| r.stop_time.strftime(TIME_FORMAT)}
         | 
| 181 | 
            -
                      table.reorder("status","run_id","version","start_time","stop_time")
         | 
| 182 | 
            -
                      ret<<table.to_html
         | 
| 183 | 
            -
                    end
         | 
| 184 | 
            -
                  rescue
         | 
| 185 | 
            -
                    puts $!
         | 
| 186 | 
            -
                    ret=p{"could not retrieve data for #{@spec_name}"}
         | 
| 187 | 
            -
                  end
         | 
| 188 | 
            -
                  return ret
         | 
| 189 | 
            -
                end
         | 
| 190 | 
            -
                private
         | 
| 191 | 
            -
                #Constructs the left panel of the page as a list of the test runs
         | 
| 192 | 
            -
                def leftpanel
         | 
| 193 | 
            -
                  div.leftpanel! do
         | 
| 194 | 
            -
                    div.graypanel(:align=>"justify") do
         | 
| 195 | 
            -
                      span.bodytext do
         | 
| 196 | 
            -
                        if @left_panel==:runs
         | 
| 197 | 
            -
                          #<img src="run_error.png" align="center"/><a href="index.html" class="smallgraytext">1 - 28.06.2007</a>
         | 
| 198 | 
            -
                          Rutema::Model::Run.find(:all,:select=>"id").reverse.each do |r|
         | 
| 199 | 
            -
                            a.smallgraytext(:href=>"?run=#{r.id}"){"Run ##{r.id}"}
         | 
| 200 | 
            -
                            br
         | 
| 201 | 
            -
                          end
         | 
| 202 | 
            -
                        elsif @left_panel==:scenarios
         | 
| 203 | 
            -
                          result=Rutema::Model::Scenario.find(:all).collect{|r| r.name}
         | 
| 204 | 
            -
                          result.uniq.sort.each do |r|
         | 
| 205 | 
            -
                            a.smallgraytext(:href=>"?scenario_name=#{r}"){"#{r}"}
         | 
| 206 | 
            -
                            br
         | 
| 207 | 
            -
                          end
         | 
| 208 | 
            -
                        end
         | 
| 209 | 
            -
                      end
         | 
| 210 | 
            -
                    end
         | 
| 211 | 
            -
                  end
         | 
| 212 | 
            -
                end
         | 
| 213 | 
            -
                
         | 
| 214 | 
            -
                #will render a hash in a table of key||value rows 
         | 
| 215 | 
            -
                def context_table context
         | 
| 216 | 
            -
                   table do
         | 
| 217 | 
            -
                      tr do
         | 
| 218 | 
            -
                        context.each do |k,v|
         | 
| 219 | 
            -
                          td {k.to_s}
         | 
| 220 | 
            -
                          td {v.to_s}
         | 
| 221 | 
            -
                        end
         | 
| 222 | 
            -
                      end
         | 
| 223 | 
            -
                    end
         | 
| 224 | 
            -
                end
         | 
| 225 | 
            -
              end
         | 
| 226 | 
            -
            end
         | 
| 227 | 
            -
             | 
| 228 | 
            -
            #Starts a WEBRick server with the RutemaWeb controller in /
         | 
| 229 | 
            -
            def start_server (port=3301,docroot=RutemaWeb::HTDOCS,mountpoint="/")
         | 
| 230 | 
            -
              include WEBrick 
         | 
| 231 | 
            -
              dbfile=ARGV.shift
         | 
| 232 | 
            -
              if !dbfile
         | 
| 233 | 
            -
                puts "please provide a database filename"
         | 
| 234 | 
            -
                exit 0
         | 
| 235 | 
            -
              end
         | 
| 236 | 
            -
              if File.exist?(dbfile)
         | 
| 237 | 
            -
                ActiveRecord::Base.establish_connection(:adapter=>"sqlite3", :database=>dbfile )
         | 
| 238 | 
            -
                s = HTTPServer.new(:Port => port, :DocumentRoot => docroot ) 
         | 
| 239 | 
            -
                s.mount mountpoint, WEBrick::CampingHandler, RutemaWeb
         | 
| 240 | 
            -
                trap("INT") { s.shutdown } 
         | 
| 241 | 
            -
                s.start
         | 
| 242 | 
            -
              else
         | 
| 243 | 
            -
                $stderr.puts "Can't find database file '#{dbfile}'"
         | 
| 244 | 
            -
              end
         | 
| 245 | 
            -
            end
         |