Sha256: f8d36856b681a13b0ab49811344450e4671ec86d0f669ff741a57b42b68dbd4d

Contents?: true

Size: 1.58 KB

Versions: 17

Compression:

Stored size: 1.58 KB

Contents

require_relative('./commandarray.rb')

class Test < CommandArray

  def update
    # rspec tests, 'rspec --pattern="**/*.spec"'
	if(Dir.glob("**/*spec.rb").length > 0)
	  self.add 'rspec'
	end

    test_files=collect_nunit_files
	if(defined?(DEV_TASKS) && DEV_TASKS.has_key?(:files) && DEV_TASKS[:files].has_key?(:test))
      test_files=DEV_TASKS[:files][:test]
	end

    if(!test_files.nil?)
    	test_files.each {|tf|
    		if(tf.include?('.dll'))
    		   nunit_dll=tf
    		  if(outputPath.include?('x86'))
    		  	self.add "\"#{Test.nunit_console_x86}\" \"#{Rake.application.original_dir}\\#{nunit_dll}\" /xml:\"#{nunit_dll}.TestResults.xml\""
    		  else
    		  	self.add "\"#{Test.nunit_console}\" \"#{Rake.application.original_dir}\\#{nunit_dll}\" /xml:\"#{nunit_dll}.TestResults.xml\""
    		  end
    		end
    	}
    end
  end

  def collect_nunit_files
  	results=Array.new
    Dir.glob("*.csproj").each{|p|
	    text = File.read(p)
		if(text.include?("nunit.framework.dll"))
		  # extract AssemblyName of form:  <AssemblyName>MyLibrary.Test</AssemblyName>
		  assemblyName=text[/<AssemblyName>([\w\.]+)</,1]
		  outputPath=text[/Release[.\w\W]+<OutputPath>([\w\.\\]+)</,1]
		  if(!assemblyName.nil? && !outputPath.nil?)
		  	results << "#{outputPath}\\#{assemblyName}.dll".gsub("\\\\","\\").gsub('/','\\')
		  end
		end
	  }
	 results
  end

  def self.nunit_console
    "C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe"
  end
  def self.nunit_console_x86
    "C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console-x86.exe"
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
dev_tasks-1.0.12 lib/test.rb
dev_tasks-1.0.11 lib/test.rb
dev_tasks-1.0.10 lib/test.rb
dev_tasks-1.0.9 lib/test.rb
dev_tasks-1.0.8 lib/test.rb
dev_tasks-1.0.7 lib/test.rb
dev_tasks-1.0.6 lib/test.rb
dev_tasks-1.0.5 lib/test.rb
dev_tasks-1.0.4 lib/test.rb
dev_tasks-1.0.3 lib/test.rb
dev_tasks-1.0.2 lib/test.rb
dev_tasks-1.0.1 lib/test.rb
dev_tasks-0.0.167 lib/test.rb
dev_tasks-1.0.0 lib/test.rb
dev_tasks-0.0.166 lib/test.rb
dev_tasks-0.0.164 lib/test.rb
dev_tasks-0.0.163 lib/test.rb