Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
builder/LogDatum: add case for failing utf decoding
Browse files Browse the repository at this point in the history
This should make it easier to see encoding issues.
  • Loading branch information
Profpatsch committed Oct 4, 2019
1 parent f6b7795 commit f3b2fdd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ fn instrumented_build(
paths.push(src);
}
LogDatum::Text(line) => log_lines.push(line),
LogDatum::NonUtf(line) => log_lines.push(line),
};

(paths, log_lines)
Expand All @@ -124,10 +125,15 @@ pub fn run(root_nix_file: &NixFile, cas: &ContentAddressable) -> Result<Info<Sto
instrumented_build(root_nix_file, cas)
}

/// Classifies the output of nix-instantiate -vv.
#[derive(Debug, PartialEq)]
enum LogDatum {
/// Nix source file (which should be tracked)
Source(PathBuf),
/// Arbitrary text (which we couldn’t otherwise classify)
Text(OsString),
/// Text which we coudn’t decode from UTF-8
NonUtf(OsString),
}

/// Examine a line of output and extract interesting log items in to
Expand All @@ -148,7 +154,7 @@ where
match line.as_ref().to_str() {
// If we can’t decode the output line to an UTF-8 string,
// we cannot match against regexes, so just pass it through.
None => LogDatum::Text(line.as_ref().to_owned()),
None => LogDatum::NonUtf(line.as_ref().to_owned()),
Some(linestr) => {
// Lines about evaluating a file are much more common, so looking
// for them first will reduce comparisons.
Expand Down

0 comments on commit f3b2fdd

Please sign in to comment.