mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
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:
parent
b249f9657c
commit
d17dcb2920
4 changed files with 20 additions and 31 deletions
|
@ -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 = ".."
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
|
|
@ -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)[..]
|
||||
}))
|
||||
|
|
Loading…
Reference in a new issue