[why] we can get hosts file from the repo lab-z9 or get hosts file from lkp-tests/hosts before: get hosts file from lab-z9, but the hosts file not exist in lkp-tests/hosts the job will puts the error message: hosts_file not exist ... but there is no need to puts such error message, if we have got the hosts file from lab-z9 --- lib/job.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/lib/job.rb b/lib/job.rb index 995b38bf..6b619b79 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -334,20 +334,14 @@ class Job end
def get_hosts_file + lab_hosts_file = get_lab_hosts_file + return lab_hosts_file if lab_hosts_file + hosts_file_name = @job['tbox_group'].split('--')[0] hosts_file = "#{LKP_SRC}/hosts/#{hosts_file_name}" + return hosts_file if File.exist?(hosts_file)
- lab_hosts_file = get_lab_hosts_file - if lab_hosts_file - hosts_file = lab_hosts_file - end - - if File.file?(hosts_file) - hosts_file - else - puts("hosts_file not exist: #{hosts_file}, maybe need check testbox field") - nil - end + raise ArgumentError, "hosts file not exist: #{hosts_file_name}, maybe need check testbox field" end
def include_files
On Thu, Nov 05, 2020 at 05:09:58PM +0800, Li Ping wrote:
[why] we can get hosts file from the repo lab-z9 or get hosts file from lkp-tests/hosts before: get hosts file from lab-z9, but the hosts file not exist in lkp-tests/hosts the job will puts the error message: hosts_file not exist ... but there is no need to puts such error message, if we have got the hosts file from lab-z9
lib/job.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/lib/job.rb b/lib/job.rb index 995b38bf..6b619b79 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -334,20 +334,14 @@ class Job end
def get_hosts_file
- lab_hosts_file = get_lab_hosts_file
- return lab_hosts_file if lab_hosts_file
- hosts_file_name = @job['tbox_group'].split('--')[0] hosts_file = "#{LKP_SRC}/hosts/#{hosts_file_name}"
- return hosts_file if File.exist?(hosts_file)
You used File.file?() before, I think you can keep use it.
Cause File.exist?(host_file) also return true if host_file is a directory.
But File.file?(host_file) == true means host_file exist and it's a file.
Thanks, Yuanchao
- lab_hosts_file = get_lab_hosts_file
- if lab_hosts_file
hosts_file = lab_hosts_file
- end
- if File.file?(hosts_file)
hosts_file
- else
puts("hosts_file not exist: #{hosts_file}, maybe need check testbox field")
nil
- end
raise ArgumentError, "hosts file not exist: #{hosts_file_name}, maybe need check testbox field" end
def include_files
-- 2.23.0
On Thu, Nov 05, 2020 at 05:19:12PM +0800, Li Yuanchao wrote:
On Thu, Nov 05, 2020 at 05:09:58PM +0800, Li Ping wrote:
[why] we can get hosts file from the repo lab-z9 or get hosts file from lkp-tests/hosts before: get hosts file from lab-z9, but the hosts file not exist in lkp-tests/hosts the job will puts the error message: hosts_file not exist ... but there is no need to puts such error message, if we have got the hosts file from lab-z9
lib/job.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/lib/job.rb b/lib/job.rb index 995b38bf..6b619b79 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -334,20 +334,14 @@ class Job end
def get_hosts_file
- lab_hosts_file = get_lab_hosts_file
- return lab_hosts_file if lab_hosts_file
- hosts_file_name = @job['tbox_group'].split('--')[0] hosts_file = "#{LKP_SRC}/hosts/#{hosts_file_name}"
- return hosts_file if File.exist?(hosts_file)
You used File.file?() before, I think you can keep use it.
Cause File.exist?(host_file) also return true if host_file is a directory.
But File.file?(host_file) == true means host_file exist and it's a file.
good! Thanks, Ping
Thanks, Yuanchao
- lab_hosts_file = get_lab_hosts_file
- if lab_hosts_file
hosts_file = lab_hosts_file
- end
- if File.file?(hosts_file)
hosts_file
- else
puts("hosts_file not exist: #{hosts_file}, maybe need check testbox field")
nil
- end
raise ArgumentError, "hosts file not exist: #{hosts_file_name}, maybe need check testbox field" end
def include_files
-- 2.23.0