Ruby 如何从Rake';谁的文件列表?
我正在编写一个rakefile,需要同时对几个测试dll运行mstest。我只需要它运行mstest一次,因为我只需要一个TRX文件。为了对多个测试dll运行mstest,我需要能够在同一个命令中添加几个Ruby 如何从Rake';谁的文件列表?,ruby,rake,rakefile,Ruby,Rake,Rakefile,我正在编写一个rakefile,需要同时对几个测试dll运行mstest。我只需要它运行mstest一次,因为我只需要一个TRX文件。为了对多个测试dll运行mstest,我需要能够在同一个命令中添加几个/testcontainer:some.test.dll实例。以下是我当前的rake任务: task :tests do testDlls = FileList.new("#{BUILD_PATH}/*.Specs.dll") sh "#{MSTEST_PATH} /testcontai
/testcontainer:some.test.dll
实例。以下是我当前的rake任务:
task :tests do
testDlls = FileList.new("#{BUILD_PATH}/*.Specs.dll")
sh "#{MSTEST_PATH} /testcontainer:#{testDlls}"
end
例如,testdll有test1.dll、test2.dll和test3.dll。上述任务输出:
c:\msbuild\msbuild.exe /testcontainer:test1.dll test2.dll test3.dll
我需要的是:
c:\msbuild\msbuild.exe /testcontainer:test1.dll /testcontainer:test2.dll /testcontainer:test3.dll
如何获得所需的输出?应该可以:
require 'shellwords'
task :tests do
testDlls = FileList.new("#{BUILD_PATH}/*.Specs.dll")
ary = Shellwords.shellwords(testDlls.to_s)
sh "#{MSTEST_PATH} #{ary.map {|dll| '/testcontainer:' + dll}.join(' ')"
end
看起来很有希望,但我又犯了一个错误。您的第四行抛出以下命令:undefined method
scan'for#C:/Ruby192/lib/ruby/1.9.1/shellwords.rb:35:in
shellsplit'