From 2dc8813cf8314d67244a5f7a977313168a3b7ad1 Mon Sep 17 00:00:00 2001 From: konstin Date: Thu, 15 Nov 2018 21:28:28 +0100 Subject: [PATCH] Improve testing setup --- .gitignore | 2 ++ Makefile | 25 +++++-------------------- ci/travis/guide.sh | 4 ++-- ci/travis/setup.sh | 4 ++-- ci/travis/test.sh | 15 ++++----------- 5 files changed, 15 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 2a2afe12..439ac2ae 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ dist/ .hypothesis/ .eggs/ venv* +guide/book/ +examples/*/py *.so *.out diff --git a/Makefile b/Makefile index a9b7d3ee..d56ee220 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,13 @@ -.PHONY: default test publish - -ifndef PY -PY := $(word 2, $(subst ., ,$(shell python --version 2>&1))) -endif - -ifeq ($(PY),2) -FEATURES := python2 -endif -ifeq ($(PY),3) -FEATURES := python3 -endif - -CARGO_FLAGS := --features "$(FEATURES)" --no-default-features - -default: test +.PHONY: test publish test: - cargo test $(CARGO_FLAGS) - pip install tox + cargo test + cargo clippy tox - cd examples/word-count && tox - cd examples/rustapi_module && tox + for example in examples/*; do tox -e py --workdir $$example; done publish: + cargo test cargo publish --manifest-path pyo3-derive-backend/Cargo.toml cargo publish --manifest-path pyo3cls/Cargo.toml cargo publish diff --git a/ci/travis/guide.sh b/ci/travis/guide.sh index ae389bcf..245bec37 100755 --- a/ci/travis/guide.sh +++ b/ci/travis/guide.sh @@ -5,10 +5,10 @@ set -ex ### Setup latest mdbook version ################################################ INSTALLED=$(echo $(mdbook --version 2>/dev/null || echo "mdbook none") | cut -d' ' -f1) -PINNED=0.1.5 +PINNED=0.2.1 if [ "$PINNED" != "$INSTALLED" ]; then - URL=https://github.com/rust-lang-nursery/mdBook/releases/download/v${PINNED}/mdbook-v${PINNED}-x86_64-unknown-linux-gnu.tar.gz + URL=https://github.com/rust-lang-nursery/mdBook/releases/download/v${PINNED}/mdbook-v${PINNED}-x86_64-unknown-linux-musl.tar.gz curl -SsL $URL | tar xvz -C $HOME/.cargo/bin fi diff --git a/ci/travis/setup.sh b/ci/travis/setup.sh index d25765cc..ca29688b 100755 --- a/ci/travis/setup.sh +++ b/ci/travis/setup.sh @@ -19,8 +19,8 @@ _latest() { curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TRAVIS_RUST_VERSION export PATH=$PATH:$HOME/.cargo/bin -rustup component add clippy-preview - +rustup component add clippy +rustup component add rustfmt ### Setup kcov ################################################################# diff --git a/ci/travis/test.sh b/ci/travis/test.sh index acd602a2..0ffd9f45 100755 --- a/ci/travis/test.sh +++ b/ci/travis/test.sh @@ -1,18 +1,11 @@ -#!/bin/sh +#!/bin/bash set -ex -cargo build --features $FEATURES -cargo clippy --features $FEATURES +cargo fmt --all -- --check cargo test --features $FEATURES +cargo clippy --features $FEATURES for example in examples/*; do - cd $example - if [ -f tox.ini ]; then - tox -e py - else - pip install -e . - pytest -v tests - fi - cd $TRAVIS_BUILD_DIR + tox -e py --workdir $example done