From d05a137eb6e7dd357c636d3b2c64a5bf88b61ce8 Mon Sep 17 00:00:00 2001 From: bennyhodl Date: Tue, 8 Oct 2024 18:40:20 -0400 Subject: [PATCH] ignore async feature in tests --- .github/workflows/rust.yml | 2 +- mocks/Cargo.toml | 2 +- p2pd-oracle-client/Cargo.toml | 3 ++- scripts/unit_tests.sh | 39 +++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100755 scripts/unit_tests.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ed5d4f4a..aa9ffb82 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -52,7 +52,7 @@ jobs: - name: Build run: cargo build --verbose - name: Test - run: cargo test --verbose --all-features + run: ./scripts/unit_tests.sh async integration_tests_prepare: runs-on: ubuntu-latest diff --git a/mocks/Cargo.toml b/mocks/Cargo.toml index 8f4ddc52..639c4a52 100644 --- a/mocks/Cargo.toml +++ b/mocks/Cargo.toml @@ -8,7 +8,7 @@ version = "0.1.0" bdk-macros = "0.6.0" bitcoin = "0.32.2" dlc = {path = "../dlc"} -dlc-manager = {path = "../dlc-manager"} +dlc-manager = {path = "../dlc-manager", default-features = false} dlc-messages = {path = "../dlc-messages"} lightning = {version = "0.0.124"} secp256k1-zkp = {version = "0.11.0", features = ["hashes", "global-context", "rand", "rand-std"]} diff --git a/p2pd-oracle-client/Cargo.toml b/p2pd-oracle-client/Cargo.toml index f8211c6a..e85cee11 100644 --- a/p2pd-oracle-client/Cargo.toml +++ b/p2pd-oracle-client/Cargo.toml @@ -5,11 +5,12 @@ homepage = "https://github.com/p2pderivatives/rust-dlc" license-file = "../LICENSE" name = "p2pd-oracle-client" repository = "https://github.com/p2pderivatives/rust-dlc/tree/master/p2pd-oracle-client" +edition = "2018" version = "0.1.0" [dependencies] chrono = {version = "0.4.19", features = ["serde"]} -dlc-manager = {path = "../dlc-manager"} +dlc-manager = {path = "../dlc-manager", default-features = false} dlc-messages = {path = "../dlc-messages", features = ["use-serde"]} reqwest = {version = "0.11", features = ["blocking", "json"]} secp256k1-zkp = {version = "0.11.0" } diff --git a/scripts/unit_tests.sh b/scripts/unit_tests.sh new file mode 100755 index 00000000..59ce045e --- /dev/null +++ b/scripts/unit_tests.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -e + +# Function to get features from a Cargo.toml file +get_features() { + local cargo_toml="$1" + yq e '.features | keys | .[]' "$cargo_toml" 2>/dev/null || true +} + +# Function to recursively find all Cargo.toml files +find_cargo_tomls() { + find . -name Cargo.toml | grep -v '/target/' +} + +# Collect all unique features +collect_features() { + local all_features=() + while IFS= read -r toml; do + while IFS= read -r feature; do + all_features+=("$feature") + done < <(get_features "$toml") + done < <(find_cargo_tomls) + printf '%s\n' "${all_features[@]}" | sort -u +} + +# Main script +EXCLUDE_FEATURE="${1:-}" +if [ -z "$EXCLUDE_FEATURE" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Collect all unique features except the excluded one +FEATURES=$(collect_features | grep -v "^$EXCLUDE_FEATURE$" | tr '\n' ',' | sed 's/,$//') + +# Run cargo test with all features except the excluded one +echo "Running tests with all features except '$EXCLUDE_FEATURE'" +cargo test --all --features "$FEATURES"