From 9efc291d281b39a13b188caf49f761b8fbaa80d0 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 12 Apr 2023 15:03:14 -0400 Subject: [PATCH] Add a script to check all sample org-mode documents with the compare program. --- scripts/compare_parse_all.bash | 27 +++++++++++++++++++++++++++ src/compare/diff.rs | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 scripts/compare_parse_all.bash diff --git a/scripts/compare_parse_all.bash b/scripts/compare_parse_all.bash new file mode 100755 index 0000000..8430d23 --- /dev/null +++ b/scripts/compare_parse_all.bash @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# +# Check that the official org-mode parser and this implementation of an org-mode parser agree on how the sample org-mode documents should be parsed. +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$DIR" + +: ${org_dir:="$DIR/../org_mode_samples"} +: ${compare_bin:="$DIR/../target/debug/org_compare"} + +test_files=$(find $org_dir -type f -name '*.org') + +cargo build --bin org_compare + + +while read test_file; do + set +e + diff_results=$("$compare_bin" "$test_file") + diff_status=$? + set -e + if [ $diff_status -eq 0 ]; then + echo "GOOD $test_file" + else + echo "BAD $test_file" + fi +done<<<"$test_files" diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 75635b8..08863d9 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -57,7 +57,7 @@ impl DiffResult { pub fn is_bad(&self) -> bool { match self.status { - DiffStatus::Good => !self.has_bad_children(), + DiffStatus::Good => self.has_bad_children(), DiffStatus::Bad => true, } }