Class: FubuRake::Storyteller

Inherits:
Object
  • Object
show all
Defined in:
lib/fuburake.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Storyteller

Returns a new instance of Storyteller.



366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# 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

Instance Method Details

#to_args(options, output) ⇒ Object



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# 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) ⇒ Object



416
417
418
419
420
421
422
423
424
425
# 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