Skip to content

Commit

Permalink
Build the test stubs with Cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
mbuesch committed Dec 30, 2024
1 parent cc20f4f commit 3931dfe
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"letmein-systemd",
"letmeind",
"letmeinfwd",
"tests/stubs/nft",
]
resolver = "2"

Expand Down
13 changes: 1 addition & 12 deletions tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ cargo_clippy()
cargo clippy --tests -- --deny warnings || die "cargo clippy --tests failed"
}

build_stubs()
{
info "Building stubs..."
mkdir -p "$tmpbin" \
|| die "Failed to create tmpbin directory"
rustc --edition 2021 -o "$tmpbin/nft" "$stubdir/nft.rs" \
|| die "Failed to build nft stub"
}

run_tests()
{
local test_type="$1"
Expand Down Expand Up @@ -152,22 +143,20 @@ pid_letmeind=
[ -n "$TMPDIR" ] || export TMPDIR=/tmp
tmpdir="$(mktemp --tmpdir="$TMPDIR" -d letmein-test.XXXXXXXXXX)"
[ -d "$tmpdir" ] || die "Failed to create temporary directory"
tmpbin="$tmpdir/bin"
rundir="$tmpdir/run"

target="$basedir/target/debug"
testdir="$basedir/tests"
stubdir="$testdir/stubs"

export PATH="$tmpbin:$PATH"
export PATH="$target:$PATH"

trap cleanup_and_exit INT TERM
trap cleanup EXIT

info "Temporary directory is: $tmpdir"
build_project
cargo_clippy
build_stubs
run_tests tcp
run_tests udp
info "All tests Ok."
Expand Down
20 changes: 20 additions & 0 deletions tests/stubs/nft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-

[package]
name = "nft-stub"
description = "letmein: nft stub for testing"
version = "0.0.0"
publish = false
edition = { workspace = true }
rust-version = { workspace = true }
license = { workspace = true }
authors = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }

[[bin]]
name = "nft"

[dependencies]

# vim: ts=4 sw=4 expandtab
File renamed without changes.

0 comments on commit 3931dfe

Please sign in to comment.