Browse Source

Results to file

master
Christian Aust 4 weeks ago
parent
commit
1b87b3c490
4 changed files with 25 additions and 3 deletions
  1. +1
    -1
      .gitignore
  2. +2
    -0
      README.md
  3. +18
    -2
      lib/sanity/runner.rb
  4. +4
    -0
      lib/sanity/suite.rb

+ 1
- 1
.gitignore View File

@ -1,5 +1,5 @@
/*.json
/run
/coverage
# rspec failure tracking

+ 2
- 0
README.md View File

@ -15,6 +15,8 @@ Taking care for a running online application requires repetitive, dull little ta
Test code is in `lib/sanity/tests` for reference and details.
Results are written to XML files, one per *application* in the targets definition. Result files are created in path `./run/*.xml`
## Example target file
Create a file `targets.json` in the base directory of this repo. It may contain multiple apps, and for each app any combination of supported tests along with any number of targets (at least one, though).

+ 18
- 2
lib/sanity/runner.rb View File

@ -1,3 +1,4 @@
require 'fileutils'
require 'json'
require 'logger'
@ -5,7 +6,11 @@ module Sanity
class Runner
attr_reader :specs
def initialize(src)
DEFAULTS = {
path: 'run'
}
def initialize(src, options={})
if src.respond_to?(:read)
# general IO
@specs = JSON.load src.read
@ -40,8 +45,19 @@ module Sanity
log.error "Invalid configuration for #{name}/#{role_name}"
end
end
puts Output::Xml.new(suite.result).to_s
write(suite)
end
end
def write(suite)
path = File.join(DEFAULTS[:path], "#{suite.result_name}.xml")
dirname = File.dirname(path)
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
File::open(path, 'w') do |f|
f << Output::Xml.new(suite.result).to_s
end
log.info("Written suite result to #{path}")
end
def self.log

+ 4
- 0
lib/sanity/suite.rb View File

@ -13,6 +13,10 @@ module Sanity
@tests << val
end
def result_name
name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
end
def result
result = Result.new(name)
@tests.each do |test|

Loading…
Cancel
Save