Justfile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. all: build test xtests
  2. all-release: build-release test-release xtests-release
  3. all-quick: build-quick test-quick xtests-quick
  4. export DOG_DEBUG := ""
  5. #----------#
  6. # building #
  7. #----------#
  8. # compile the dog binary
  9. @build:
  10. cargo build
  11. # compile the dog binary (in release mode)
  12. @build-release:
  13. cargo build --release --verbose
  14. strip "${CARGO_TARGET_DIR:-target}/release/dog"
  15. # produce an HTML chart of compilation timings
  16. @build-time:
  17. cargo +nightly clean
  18. cargo +nightly build -Z timings
  19. # compile the dog binary (without some features)
  20. @build-quick:
  21. cargo build --no-default-features
  22. # check that the dog binary can compile
  23. @check:
  24. cargo check
  25. #---------------#
  26. # running tests #
  27. #---------------#
  28. # run unit tests
  29. @test:
  30. cargo test --workspace -- --quiet
  31. # run unit tests (in release mode)
  32. @test-release:
  33. cargo test --workspace --release --verbose
  34. # run unit tests (without some features)
  35. @test-quick:
  36. cargo test --workspace --no-default-features -- --quiet
  37. # run mutation tests
  38. @test-mutation:
  39. cargo +nightly test --package dns --features=dns/with_mutagen -- --quiet
  40. cargo +nightly mutagen --package dns --features=dns/with_mutagen
  41. #------------------------#
  42. # running extended tests #
  43. #------------------------#
  44. # run extended tests
  45. @xtests *args:
  46. specsheet xtests/{options,live,madns}/*.toml -shide {{args}} \
  47. -O cmd.target.dog="${CARGO_TARGET_DIR:-../../target}/debug/dog"
  48. # run extended tests (in release mode)
  49. @xtests-release *args:
  50. specsheet xtests/{options,live,madns}/*.toml {{args}} \
  51. -O cmd.target.dog="${CARGO_TARGET_DIR:-../../target}/release/dog"
  52. # run extended tests (omitting certain feature tests)
  53. @xtests-quick *args:
  54. specsheet xtests/options/*.toml xtests/live/{basics,tcp}.toml -shide {{args}} \
  55. -O cmd.target.dog="${CARGO_TARGET_DIR:-../../target}/debug/dog"
  56. # run extended tests against a local madns instance
  57. @xtests-madns-local *args:
  58. env MADNS_ARGS="@localhost:5301 --tcp" \
  59. specsheet xtests/madns/*.toml -shide {{args}} \
  60. -O cmd.target.dog="${CARGO_TARGET_DIR:-../../target}/debug/dog"
  61. # display the number of extended tests that get run
  62. @count-xtests:
  63. grep -F '[[cmd]]' -R xtests | wc -l
  64. #---------#
  65. # fuzzing #
  66. #---------#
  67. # run fuzzing on the dns crate
  68. @fuzz:
  69. cargo +nightly fuzz --version
  70. cd dns; cargo +nightly fuzz run fuzz_parsing -- -jobs=`nproc` -workers=`nproc` -runs=69105
  71. # print out the data that caused crashes during fuzzing as hexadecimal
  72. @fuzz-hex:
  73. for crash in dns/fuzz/artifacts/fuzz_parsing/crash-*; do echo; echo $crash; hexyl $crash; done
  74. # remove fuzz log files
  75. @fuzz-clean:
  76. rm dns/fuzz/fuzz-*.log
  77. #-----------------------#
  78. # code quality and misc #
  79. #-----------------------#
  80. # lint the code
  81. @clippy:
  82. touch dns/src/lib.rs
  83. cargo clippy
  84. # generate a code coverage report using tarpaulin via docker
  85. @coverage-docker:
  86. docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin cargo tarpaulin --all --out Html
  87. # update dependency versions, and check for outdated ones
  88. @update-deps:
  89. cargo update
  90. command -v cargo-outdated >/dev/null || (echo "cargo-outdated not installed" && exit 1)
  91. cargo outdated
  92. # list unused dependencies
  93. @unused-deps:
  94. command -v cargo-udeps >/dev/null || (echo "cargo-udeps not installed" && exit 1)
  95. cargo +nightly udeps
  96. # builds dog and runs extended tests with features disabled
  97. @feature-checks *args:
  98. cargo build --no-default-features
  99. specsheet xtests/features/none.toml -shide {{args}} \
  100. -O cmd.target.dog="${CARGO_TARGET_DIR:-../../target}/debug/dog"
  101. # print versions of the necessary build tools
  102. @versions:
  103. rustc --version
  104. cargo --version
  105. #---------------#
  106. # documentation #
  107. #---------------#
  108. # render the documentation
  109. @doc:
  110. cargo doc --no-deps --workspace
  111. # build the man pages
  112. @man:
  113. mkdir -p "${CARGO_TARGET_DIR:-target}/man"
  114. pandoc --standalone -f markdown -t man man/dog.1.md > "${CARGO_TARGET_DIR:-target}/man/dog.1"
  115. # build and preview the man page
  116. @man-preview: man
  117. man "${CARGO_TARGET_DIR:-target}/man/dog.1"
  118. #-----------#
  119. # packaging #
  120. #-----------#
  121. # create a distributable package
  122. zip desc exe="dog":
  123. #!/usr/bin/env perl
  124. use Archive::Zip;
  125. -e 'target/release/{{ exe }}' || die 'Binary not built!';
  126. -e 'target/man/dog.1' || die 'Man page not built!';
  127. my $zip = Archive::Zip->new();
  128. $zip->addFile('completions/dog.bash');
  129. $zip->addFile('completions/dog.zsh');
  130. $zip->addFile('completions/dog.fish');
  131. $zip->addFile('target/man/dog.1', 'man/dog.1');
  132. $zip->addFile('target/release/{{ exe }}', 'bin/{{ exe }}');
  133. $zip->writeToFileNamed('dog-{{ desc }}.zip') == AZ_OK || die 'Zip write error!';
  134. system 'unzip -l "dog-{{ desc }}".zip'