Skip to content

Commit

Permalink
ignore async feature in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyhodl committed Oct 8, 2024
1 parent b970675 commit 6157870
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Build
run: cargo build --verbose
- name: Test
run: cargo test --verbose --all-features
run: ./scripts/unit_tests.sh

integration_tests_prepare:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion mocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
Expand Down
3 changes: 2 additions & 1 deletion p2pd-oracle-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
39 changes: 39 additions & 0 deletions scripts/unit_tests.sh
Original file line number Diff line number Diff line change
@@ -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 <feature_to_exclude>"
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"

0 comments on commit 6157870

Please sign in to comment.