Skip to content

Commit

Permalink
Add regex support to replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez authored and Thomas Bracht Laumann Jespersen committed Aug 7, 2018
1 parent 157b015 commit 26a8d6b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ diff = "0.1.10"
filetime = "0.2"
getopts = "0.2"
log = "0.4"
regex = "1.0"
tempfile = { version = "3.0", optional = true }
serde = "1.0"
serde_json = "1.0"
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern crate test;

#[macro_use]
extern crate log;
extern crate regex;
extern crate filetime;
extern crate diff;
extern crate serde_json;
Expand Down
4 changes: 3 additions & 1 deletion src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use diff;
use errors::{self, ErrorKind, Error};
use filetime::FileTime;
use json;
use regex::Regex;
use header::TestProps;
use util::logv;

Expand Down Expand Up @@ -2454,7 +2455,8 @@ actual:\n\
.replace("\r\n", "\n") // normalize for linebreaks on windows
.replace("\t", "\\t"); // makes tabs visible
for rule in custom_rules {
normalized = normalized.replace(&rule.0, &rule.1);
let re = Regex::new(&rule.0).expect("bad regex in custom normalization rule");
normalized = re.replace_all(&normalized, &rule.1[..]).into_owned();
}
normalized
}
Expand Down

0 comments on commit 26a8d6b

Please sign in to comment.