Browse Source

fix: Separate cache from output files in yml report

Otherwise the output may look non-deterministic if there are stale files in
the cache.
tags/0.1
Cory Fields 6 years ago
parent
commit
00114ee98f
1 changed files with 10 additions and 5 deletions
  1. 10
    5
      bin/gbuild

+ 10
- 5
bin/gbuild View File

@@ -259,9 +259,11 @@ suites.each do |suite|
end

out_dir = File.join(build_dir, "out")
out_sums = {}
cache_common_dir = File.join(cache_dir, "common")
cache_package_dir = File.join(cache_dir, "#{package_name}")
out_sums = {}
cache_common_sums = {}
cache_package_sums = {}

info "Generating report"
Dir.glob(File.join(out_dir, '**', '*'), File::FNM_DOTMATCH).sort.each do |file_in_out|
@@ -277,29 +279,32 @@ Dir.glob(File.join(cache_common_dir, '**', '*'), File::FNM_DOTMATCH).sort.each d
next if File.directory?(file_in_out)
file = file_in_out.sub(cache_common_dir + File::SEPARATOR, '')
file = sanitize_path(file, file_in_out)
out_sums[file] = `cd #{cache_common_dir} && sha256sum #{file}`
cache_common_sums[file] = `cd #{cache_common_dir} && sha256sum #{file}`
raise "failed to sum #{file}" unless $? == 0
puts out_sums[file] unless @options[:quiet]
end

Dir.glob(File.join(cache_package_dir, '**', '*'), File::FNM_DOTMATCH).sort.each do |file_in_out|
next if File.directory?(file_in_out)
file = file_in_out.sub(cache_package_dir + File::SEPARATOR, '')
file = sanitize_path(file, file_in_out)
out_sums[file] = `cd #{cache_package_dir} && sha256sum #{file}`
cache_package_sums[file] = `cd #{cache_package_dir} && sha256sum #{file}`
raise "failed to sum #{file}" unless $? == 0
puts out_sums[file] unless @options[:quiet]
end

out_manifest = out_sums.keys.sort.map { |key| out_sums[key] }.join('')

in_manifest = in_sums.join('')

cache_common_manifest = cache_common_sums.keys.sort.map { |key| cache_common_sums[key] }.join('')
cache_package_manifest = cache_package_sums.keys.sort.map { |key| cache_package_sums[key] }.join('')

# Use Omap to keep result deterministic
report = YAML::Omap[
'out_manifest', out_manifest,
'in_manifest', in_manifest,
'base_manifests', base_manifests,
'cache_common_manifest', cache_common_manifest,
'cache_package_manifest', cache_package_manifest,
]

result_file = "#{package_name}-res.yml"

Loading…
Cancel
Save