1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#!/usr/bin/env just --justfile
[private]
default:
@just --list
# Setup the development environment.
setup-dev:
# Sudo is required to install packages with apt
@echo Installing required packages from apt
@sudo apt-get install bear valgrind libapt-pkg-dev dpkg-dev clang-format codespell -y
@just setup-toolchain
[private]
@setup-toolchain:
#!/bin/sh
set -e
echo Setting up toolchains
rustup toolchain install nightly
rustup toolchain install stable
echo Installing nightly \`rustfmt\`
rustup toolchain install nightly --component rustfmt
echo Nightly \`rustfmt\` successfully installed!
echo Cleaning and building c++ compile commands
cargo clean
bear -- cargo build
echo Development environment installed successfully!
# Run checks
check: spellcheck clippy
@cargo +nightly fmt --check
@echo Checks were successful!
# Remove generated artifacts
clean:
@cargo clean
@echo Done!
# Build the project
build:
@cargo build
@echo Project successfully built!
# Generate docs
doc:
@cargo doc
@echo Documentation successfully generated!
# Create the debs required for tests
[private]
@create-test-debs:
#!/bin/sh
set -e
cd tests/files/cache
rm -f *.deb Packages*
for pkg in *; do
dpkg-deb --build --nocheck "${pkg}";
done
dpkg-scanpackages --multiversion . /dev/null > Packages
# Create an empty garbage package to make sure it fails
echo "\n" > pkg.deb
# Run all tests except for root
test +ARGS="":
@just create-test-debs
@cargo test --no-fail-fast -- --test-threads 1 --skip root --skip update {{ARGS}}
# Run only the root tests. Sudo password required!
@test-root +ARGS="":
#!/bin/sh
set -e
just create-test-debs
sudo -E /home/${USER}/.cargo/bin/cargo \
test \
--test root \
-- --test-threads 1 {{ARGS}}
# Run leak tests. Requires root
@leak:
#!/bin/sh
set -e
just create-test-debs
cargo test --no-run
test_binaries=$( \
find target/debug/deps -executable -type f \
-printf "%T@ %p\n" | sort -nr | awk '{print $2}' \
| grep -v ".so"
)
for test in $test_binaries; do
# Sudo is needed to memleak the root tests
sudo valgrind --leak-check=full -- "${test}" --test-threads 1
done
# Lint the codebase
clippy +ARGS="":
@cargo clippy --all-targets --all-features --workspace -- --deny warnings {{ARGS}}
@echo Lint successful!
# Format the codebase
@fmt +ARGS="":
#!/bin/sh
set -e
cargo +nightly fmt --all -- {{ARGS}}
cd apt-pkg-c
clang-format -i *
echo Codebase formatted successfully!
# Spellcheck the codebase
spellcheck +ARGS="":
@codespell --skip target --skip .git --skip .cargo --builtin clear,rare,informal,code --ignore-words-list mut,crate {{ARGS}}
@echo Spellings look good!
alias b := build
alias c := check
alias d := doc
alias l := leak
alias t := test
alias r := test-root
|