Как я могу отформатировать новую строку из FileList Rake?

Я пишу rakefile, и мне нужно запустить mstest одновременно с несколькими тестовыми dll. Мне нужно запустить mstest только один раз, потому что мне нужен только один файл TRX. Чтобы запустить mstest для нескольких тестовых dll, мне нужно иметь возможность добавить несколько экземпляров /testcontainer:some.test.dll в одну и ту же команду. Вот моя текущая рейк-задача:

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

Как я могу получить желаемый результат?


person Byron Sommardahl    schedule 07.01.2011    source источник


Ответы (1)


Это должно работать:

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
person Guilherme Bernal    schedule 08.01.2011
comment
Это выглядит многообещающе, но я получаю другую ошибку. Ваша 4-я строка выдает это: undefined method scan' for #<Rake::FileList:0x5162d0> C:/Ruby192/lib/ruby/1.9.1/shellwords.rb:35:in shellsplit' - person Byron Sommardahl; 08.01.2011