imp(clap-test): simplified make test invocation

* assure `make test` works on OSX as well
* simplified entire makefile, by basically removing sed invocations to
  manipulate the Cargo.toml file under source control.
* *works for me* predicate

This should probably be tested on another system as well, just to be
sure it makes sense for everyone.
This commit is contained in:
Sebastian Thiel 2015-05-05 10:33:27 +02:00 committed by Kevin K
parent b249f9657c
commit d17dcb2920
4 changed files with 20 additions and 31 deletions

View file

@ -5,5 +5,4 @@ version = "0.0.1"
authors = ["Kevin K. <kbknapp@gmail.com>"]
[dependencies.clap]
git = "https://github.com/kbknapp/clap-rs"
branch = "master"
path = ".."

View file

@ -1,30 +1,14 @@
THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
URL:=
BRANCH:=
.PHONY: build test clean
build:
cargo update
# It may be that this project was never built, and no Cargo.lock exists.
# Thus it may be ignored
cargo update 2>/dev/null || :
cargo build --release
test:
cd "$(THIS_DIR)"
cp Cargo.toml cargo.bak
@read -p "Fork URL: " URL; \
sed "/^git/c\git = \"$$URL\"" cargo.bak > Cargo.toml
@read -p "Branch [master]: " BRANCH; \
$(if $(strip $(BRANCH)), \
sed -i "/^branch/c\branch = \"master\"" Cargo.toml, \
sed -i "/^branch/c\branch = \"$$BRANCH\"" Cargo.toml)
(make clean) || (make clean && false)
cd "$(THIS_DIR)"
(make build) || (make clean && false)
cd "$(THIS_DIR)"
(./run_tests.py) || (make clean && false)
mv cargo.bak Cargo.toml
make clean
$(MAKE) build || ($(MAKE) clean && false)
./run_tests.py
clean:
cd "$(THIS_DIR)"
cargo clean

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
import subprocess

View file

@ -397,13 +397,15 @@ macro_rules! arg_enum {
type Err = String;
fn from_str(s: &str) -> Result<Self,Self::Err> {
use ::std::ascii::AsciiExt;
match s {
$(stringify!($v) => Ok($e::$v),)+
$(stringify!($v) |
_ if s.eq_ignore_ascii_case(stringify!($v)) => Ok($e::$v),)+
_ => Err({
let v = vec![
$(stringify!($v),)+
];
format!("valid:{}",
format!("valid values:{}",
v.iter().fold(String::new(), |a, i| {
a + &format!(" {}", i)[..]
}))
@ -422,13 +424,15 @@ macro_rules! arg_enum {
type Err = String;
fn from_str(s: &str) -> Result<Self,Self::Err> {
use ::std::ascii::AsciiExt;
match s {
$(stringify!($v) => Ok($e::$v),)+
$(stringify!($v) |
_ if s.eq_ignore_ascii_case(stringify!($v)) => Ok($e::$v),)+
_ => Err({
let v = vec![
$(stringify!($v),)+
];
format!("valid:{}",
format!("valid values:{}",
v.iter().fold(String::new(), |a, i| {
a + &format!(" {}", i)[..]
}))
@ -447,13 +451,15 @@ macro_rules! arg_enum {
type Err = String;
fn from_str(s: &str) -> Result<Self,Self::Err> {
use ::std::ascii::AsciiExt;
match s {
$(stringify!($v) => Ok($e::$v),)+
$(stringify!($v) |
_ if s.eq_ignore_ascii_case(stringify!($v)) => Ok($e::$v),)+
_ => Err({
let v = vec![
$(stringify!($v),)+
];
format!("valid:{}",
format!("valid values:{}",
v.iter().fold(String::new(), |a, i| {
a + &format!(" {}", i)[..]
}))