Ruby中路径的短文件名(8.3文件名)与长文件名

时间:2018-09-12 12:29:00

标签: ruby windows rspec azure-pipelines

我正在开发一个测试套件,该套件还可以比较路径的负载,例如像这样的东西:

expect(all_classes).to contain_exactly(
  File.expand_path("lib/#{plugin_info.actions_path}/#{plugin_name}_action.rb"),
  File.expand_path("lib/#{plugin_info.helper_path}/#{plugin_name}_helper.rb")
)

不幸的是,在Windows上,如果生成的临时路径包含触发8.3 filenames的目录,有时会导致测试失败。一个例子:

2018-09-11T20:52:42.9346535Z   1) Fastlane::PluginGenerator#generate creates a plugin.rb file for the plugin
2018-09-11T20:52:42.9346797Z      Failure/Error:
2018-09-11T20:52:42.9347031Z        expect(all_classes).to contain_exactly(
2018-09-11T20:52:42.9347330Z          File.expand_path("lib/#{plugin_info.actions_path}/#{plugin_name}_action.rb"),
2018-09-11T20:52:42.9347673Z          File.expand_path("lib/#{plugin_info.helper_path}/#{plugin_name}_helper.rb")
2018-09-11T20:52:42.9347922Z        )
2018-09-11T20:52:42.9348040Z 
2018-09-11T20:52:42.9348443Z        expected collection contained:  ["C:/Users/VSSADM~1/AppData/Local/Temp/d20180911-3656-1muipt1/fastlane-plugin-tester_thing/lib/fastla...muipt1/fastlane-plugin-tester_thing/lib/fastlane/plugin/tester_thing/helper/tester_thing_helper.rb"]
2018-09-11T20:52:42.9349108Z        actual collection contained:    ["C:/Users/VssAdministrator/AppData/Local/Temp/d20180911-3656-1muipt1/fastlane-plugin-tester_thing/li...muipt1/fastlane-plugin-tester_thing/lib/fastlane/plugin/tester_thing/helper/tester_thing_helper.rb"]
2018-09-11T20:52:42.9349732Z        the missing elements were:      ["C:/Users/VSSADM~1/AppData/Local/Temp/d20180911-3656-1muipt1/fastlane-plugin-tester_thing/lib/fastla...muipt1/fastlane-plugin-tester_thing/lib/fastlane/plugin/tester_thing/helper/tester_thing_helper.rb"]
2018-09-11T20:52:42.9350359Z        the extra elements were:        ["C:/Users/VssAdministrator/AppData/Local/Temp/d20180911-3656-1muipt1/fastlane-plugin-tester_thing/li...muipt1/fastlane-plugin-tester_thing/lib/fastlane/plugin/tester_thing/helper/tester_thing_helper.rb"]
2018-09-11T20:52:42.9350855Z      # ./fastlane/spec/plugins_specs/plugin_generator_spec.rb:135:in `block (4 levels) in <top (required)>'
2018-09-11T20:52:42.9351199Z      # ./fastlane/spec/plugins_specs/plugin_generator_spec.rb:119:in `chdir'
2018-09-11T20:52:42.9351541Z      # ./fastlane/spec/plugins_specs/plugin_generator_spec.rb:119:in `block (3 levels) in <top (required)>'

在这种情况下,问题出在Azure DevOps管道计算机上生成的temp目录的路径中:C:/Users/VssAdministrator/AppData/...C:/Users/VSSADM~1/AppData/...

某些ruby方法似乎返回长版本,而另一些则返回短版本。复杂的是,似乎相同的方法有时会返回一个方法,然后又返回另一个方法-取决于我尚不了解的某些上下文,至少在经过一点调试失败后,这对我来说似乎是这样。

有人可以向我解释正在发生的事情以及如何解决此问题的任何想法吗?有没有一种方法可以使表示路径的“方法”中的所有内容“标准化”?
为了解决这个问题,我还需要阅读或查看吗?

0 个答案:

没有答案