2022-01-31 15:53:02 -05:00
|
|
|
#! /usr/bin/env ruby
|
|
|
|
|
|
|
|
|
|
require "pathname"
|
|
|
|
|
require "shellwords"
|
|
|
|
|
|
|
|
|
|
project_path = ARGV[0]
|
|
|
|
|
|
|
|
|
|
Dir.chdir(project_path)
|
|
|
|
|
|
2022-02-01 14:25:47 -05:00
|
|
|
expected_files = Dir["_expected/**/*"].select { |path| File.file?(path) }.map { |path| Pathname.new(path).relative_path_from("_expected").to_s }
|
|
|
|
|
actual_files = Dir["_site/**/*"].select { |path| File.file?(path) }.map { |path| Pathname.new(path).relative_path_from("_site").to_s }
|
2022-01-31 15:53:02 -05:00
|
|
|
|
|
|
|
|
differences = []
|
|
|
|
|
|
|
|
|
|
expected_files.each do |expected_file|
|
|
|
|
|
if actual_files.include?(expected_file)
|
2022-02-02 12:39:12 -05:00
|
|
|
diff = `diff #{Shellwords.escape(File.join("_expected", expected_file))} #{Shellwords.escape(File.join("_site", expected_file))}`
|
2022-01-31 15:53:02 -05:00
|
|
|
if !$?.success?
|
|
|
|
|
differences << "Expected output of #{expected_file} differs:\n#{diff}"
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
differences << "Missing expected file: #{expected_file}"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
unexpected_files = actual_files - expected_files
|
|
|
|
|
unexpected_files.each do |unexpected_file|
|
|
|
|
|
differences << "Unexpected file: #{unexpected_file}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if !differences.empty?
|
|
|
|
|
STDERR.puts "Differences between expected and actual outputs:"
|
|
|
|
|
differences.each { |diff| STDERR.puts(diff) }
|
|
|
|
|
exit(1)
|
|
|
|
|
end
|