Rescue File.expand_path in MSpecScript#try_load if HOME is unavailable

mspec tries to load ~/.mspecrc, but some platforms (e.g. WASI) doesn't
have HOME concept, so `~` cannot be expanded and `File.expand_path` can
fail.
This commit is contained in:
Yuta Saito 2022-02-17 17:31:40 +00:00 коммит произвёл Hiroshi SHIBATA
Родитель 8a9dfb676b
Коммит 3f387e60ef
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -84,7 +84,12 @@ class MSpecScript
names.each do |name|
config[:path].each do |dir|
file = File.expand_path name, dir
begin
file = File.expand_path name, dir
rescue ArgumentError
# File.expand_path can issue error e.g. if HOME is not available
next
end
if @loaded.include?(file)
return true
elsif File.exist? file