Sha256: 714215658c6dd9fe10aa5df5c06d6814f5313edba2553b5b7c9b0506117acc85

Contents?: true

Size: 1.81 KB

Versions: 19

Compression:

Stored size: 1.81 KB

Contents

require_relative('./commandarray.rb')

class Test < CommandArray

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

    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(nunit_dll.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
    nunit="C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console.exe"
    nunit="C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe" if(!File.exists?(nunit))
    nunit
  end
  def self.nunit_console_x86
    nunit="C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console-x86.exe"
    nunit="C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console-x86.exe" if(!File.exists?(nunit))
    nunit
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
dev_tasks-1.0.35 lib/test.rb
dev_tasks-1.0.34 lib/test.rb
dev_tasks-1.0.33 lib/test.rb
dev_tasks-1.0.31 lib/test.rb
dev_tasks-1.0.30 lib/test.rb
dev_tasks-1.0.29 lib/test.rb
dev_tasks-1.0.28 lib/test.rb
dev_tasks-1.0.27 lib/test.rb
dev_tasks-1.0.26 lib/test.rb
dev_tasks-1.0.25 lib/test.rb
dev_tasks-1.0.24 lib/test.rb
dev_tasks-1.0.23 lib/test.rb
dev_tasks-1.0.22 lib/test.rb
dev_tasks-1.0.21 lib/test.rb
dev_tasks-1.0.20 lib/test.rb
dev_tasks-1.0.19 lib/test.rb
dev_tasks-1.0.18 lib/test.rb
dev_tasks-1.0.17 lib/test.rb
dev_tasks-1.0.16 lib/test.rb