2011-01-07 5 views
0

私はrakefileを書いているので、一度にいくつかのテストDLLに対してmstestを実行する必要があります。私はTRXファイルが1つだけ必要なので、mstestを1回だけ実行する必要があります。複数のテストDLLに対してmstestを実行するには、同じコマンドに/testcontainer:some.test.dllという複数のインスタンスを追加できる必要があります。現在のレイタスクは次のとおりです。RakeのFileListから新しい文字列をどのようにフォーマットできますか?

task :tests do 
    testDlls = FileList.new("#{BUILD_PATH}/*.Specs.dll") 
sh "#{MSTEST_PATH} /testcontainer:#{testDlls}"  
end 

たとえば、testDllsには​​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 

どのように私は私の所望の出力を得ることができますか?動作するはず

答えて

2

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 
+0

それは有望に見えるが、私は別のエラーを取得しています。あなたの4番目の行はこれをスローします: #Rake :: FileList:0x5162d0のための未定義メソッド 'scan ' C:/Ruby192/lib/ruby/1.9.1/shellwords.rb:35:' shellsplit' –

+0

'.to_s'から' testDlls'までです。 (編集) –

+0

ありがとう!それが機能しました。私はレースに出ます。 –

関連する問題