From a35de29355dc85f63e0e8514a2e447bf5322ba20 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 30 May 2020 15:05:36 +0100 Subject: Commit grammar file locally The crate publishing process does not allow access to files outside the current crate. --- dhall/src/syntax/text/parser.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'dhall/src/syntax/text/parser.rs') diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index dcaf5e4..486030f 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -1063,3 +1063,32 @@ pub fn parse_expr(input_str: &str) -> ParseResult { [expression(e)] => e, )) } + +#[test] +// Check that the local copy of the grammar file is in sync with the one from dhall-lang. +fn test_grammar_files_in_sync() { + use std::process::Command; + + let spec_abnf_path = "../dhall-lang/standard/dhall.abnf"; + let local_abnf_path = "src/syntax/text/dhall.abnf"; + + let out = Command::new("git") + .arg("diff") + .arg("--no-index") + .arg("--ignore-space-change") + .arg("--color") + .arg("--") + .arg(spec_abnf_path) + .arg(local_abnf_path) + .output() + .expect("failed to run `git diff` command"); + + if !out.status.success() { + let output = String::from_utf8_lossy(&out.stdout); + panic!( + "The local dhall.abnf file differs from the one from \ + dhall-lang!\n{}", + output + ); + } +} -- cgit v1.2.3