Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 如何从Rake';谁的文件列表?_Ruby_Rake_Rakefile - Fatal编程技术网

Ruby 如何从Rake';谁的文件列表?

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

我正在编写一个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} /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'