-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There is no expected output committed to the repo yet, so it is expected to fail.
- Loading branch information
Jess Bees
committed
Feb 1, 2022
1 parent
c96882a
commit ac02ba7
Showing
2 changed files
with
54 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #! /usr/bin/env ruby | ||
|
|
||
| require "pathname" | ||
| require "shellwords" | ||
|
|
||
| project_path = ARGV[0] | ||
|
|
||
| Dir.chdir(project_path) | ||
|
|
||
| expected_files = Dir["_expected/**/*"].map { |path| Pathname.new(path).relative_path_from("_expected").to_s } | ||
| actual_files = Dir["_site/**/*"].map { |path| Pathname.new(path).relative_path_from("_site").to_s } | ||
|
|
||
| differences = [] | ||
|
|
||
| expected_files.each do |expected_file| | ||
| if actual_files.include?(expected_file) | ||
| # TODO: consider -b to ignore whitespace, or -B for ignore blank lines, or --strip-trailing-cr | ||
| diff = `diff #{Shellwords.escape(File.join("_expected", expected_file))} #{Shellwords.escape(File.join("_site", expected_file))}` | ||
| 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 |