class FubuRake::Storyteller

Public Class Methods

new(options) click to toggle source
# File lib/fuburake.rb, line 366
def initialize(options)
        # :path
        # :compilemode -- take it from @solution.compiletarget
        # :results
        # :workspace
        # :profile
        # :title
        # :source
        # :prefix
        # :st_path
        # :specs

        @directory = options[:dir]
        @prefix = options.fetch(:prefix, 'st')
        @src = options.fetch(:source, 'src')
        @results = options.fetch(:results, 'st-results/index.htm')
        @st_path = options.fetch(:st_path, "#{@src}/packages/Storyteller2/tools")
        @title = options.fetch(:title, 'Storyteller Specs')
        @specs = options.fetch(:specs, 'specs')
        @suites = options.fetch(:suites, [])

        to_task 'run', 'ST.exe', "run #{to_args(options, @results)}", "Run the Storyteller tests for #{@directory}"
        to_task 'specs', 'ST.exe', "specs #{to_args(options, @specs)} --title \"#{@title}\"", "dump the specs for Storyteller tests at #{@directory}"
        
        if @suites.length == 0
                Dir["#{options[:path]}/Tests/*/"].each do |f|
                        @suites.push f.split('/').last
                end
        end
        
        @suites.each do |s|
                to_task "run:#{s.downcase}", 'ST.exe', "run #{to_args(options, @results)} -w #{s}", "Run Storyteller suite #{s}"
        end

        if !Platform.is_nix
                # StoryTellerUI.exe is a WPF application which is
                # not supported on nix and therefore setting up the task
                # is pointless.
                openTask = Rake::Task.define_task "#{@prefix}:open" do
                        tool = 'StoryTellerUI.exe'
                        cmd = Platform.runtime("#{File.join(@st_path, tool)}") + " #{to_args(options, @results)}"
                        puts "Opening the Storyteller UI to #{@directory}"
                        sh cmd
                end
                openTask.add_description "Open the Storyteller UI for tests at #{@directory}"
                openTask.enhance [:compile]
        end
end

Public Instance Methods

to_args(options, output) click to toggle source
# File lib/fuburake.rb, line 427
def to_args(options, output)
        args = "#{options[:path]} #{output}"

        if (options[:compilemode] != nil)
                args += " --compile #{options[:compilemode]}"
        end

        if (options[:workspace] != nil)
                args += " --workspace #{options[:workspace]}"
        end

        if (options[:profile] != nil)
                args += " --profile #{options[:profile]}"
        end

        if (options[:timeout] != nil)
                args += " --timeout #{options[:timeout]}"
        end

        return args
end
to_task(name, tool, args, description) click to toggle source
# File lib/fuburake.rb, line 416
def to_task(name, tool, args, description)
        task = Rake::Task.define_task "#{@prefix}:#{name}" do
                sh Platform.runtime("#{File.join(@st_path, tool)}") + " #{args}"
        end

        task.add_description description
        task.enhance [:compile]

        return task
end