From e9447a3c6ce3f2c3b057ae71a1949d6663bc1fe7 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 27 Apr 2016 16:06:56 -0400 Subject: Makefile: Add some new targets To save me some time from having to write commands. Started with a `reinstall` target to make it easier to put a new build on my PATH. Then added a `test-all` target so I wouldn't have to use two commands to run both test suites. Needed to create a `test` task also in order to run the unit tests before the integration test. Ensure that we `cargo build` before running integration tests. Otherwise we might be testing against an old build. --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 3204ff4..c7b665e 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,12 @@ test-integration: + cargo build prove -v + +test: + cargo test + +test-all: test test-integration + +reinstall: + cargo uninstall alias-auto-add + cargo install -- cgit v1.2.3 From f45f00cbbe32d473deb4e23e8944a5a61e5f8e45 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 27 Apr 2016 16:46:07 -0400 Subject: main: Ignore errors, don't write to STDERR Well, after all that error handling I'm going to have to remove error output. The problem was that this STDERR output interfered with the output of the email in Mutt. When viewing a message, the screen would become mangled (for certain messages), and I'd have to refresh (Ctrl-L) the view. After initially thinking this was because I was using `println!` instead of flushing a full buffer to STDOUT, I just now realised that my output to STDERR could be causing the problem. Sure enough, removing the STDERR output fixed the issue. This is certainly not ideal, so in the long term we'll probably want to add some kind of logging mechanism so that users actually have visibility into errors. But for now and for my own personal purposes, I think this works. And at least it gets me around the immediate annoying screen mangling issue. --- src/main.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1129ec7..8b9c93a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ //! person has multiple email addresses. use std::env; -use std::io::{self, BufRead, Write}; +use std::io::{self, BufRead}; mod alias; @@ -42,12 +42,7 @@ fn main() { if line.starts_with("From: ") { let mut alias = Alias::new(&line); - match alias.write_to_file(&file) { - Ok(_) => continue, - Err(e @ AliasSearchError::NotFound) | Err(e @ AliasSearchError::EmailExists) => - io::stderr().write(e.to_string().as_bytes()).ok(), - Err(e) => io::stderr().write(e.to_string().as_bytes()).ok(), - }; + alias.write_to_file(&file).ok(); } } } -- cgit v1.2.3