Justfile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. # display the number of extended tests that get run
  57. @count-xtests:
  58. grep -F '[[cmd]]' -R xtests | wc -l
  59. #---------#
  60. # fuzzing #
  61. #---------#
  62. # run fuzzing on the dns crate
  63. @fuzz:
  64. cargo +nightly fuzz --version
  65. cd dns; cargo +nightly fuzz run fuzz_parsing -- -jobs=`nproc` -workers=`nproc` -runs=69105
  66. # print out the data that caused crashes during fuzzing as hexadecimal
  67. @fuzz-hex:
  68. for crash in dns/fuzz/artifacts/fuzz_parsing/crash-*; do echo; echo $crash; hexyl $crash; done
  69. # remove fuzz log files
  70. @fuzz-clean:
  71. rm dns/fuzz/fuzz-*.log
  72. #-----------------------#
  73. # code quality and misc #
  74. #-----------------------#
  75. # lint the code
  76. @clippy:
  77. touch dns/src/lib.rs
  78. cargo clippy
  79. # generate a code coverage report using tarpaulin via docker
  80. @coverage-docker:
  81. docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin cargo tarpaulin --all --out Html
  82. # update dependency versions, and check for outdated ones
  83. @update-deps:
  84. cargo update
  85. command -v cargo-outdated >/dev/null || (echo "cargo-outdated not installed" && exit 1)
  86. cargo outdated
  87. # list unused dependencies
  88. @unused-deps:
  89. command -v cargo-udeps >/dev/null || (echo "cargo-udeps not installed" && exit 1)
  90. cargo +nightly udeps
  91. # builds dog and runs extended tests with features disabled
  92. @feature-checks *args:
  93. cargo build --no-default-features
  94. specsheet xtests/features/none.toml -shide {{args}} \
  95. -O cmd.target.dog="${CARGO_TARGET_DIR:-../../target}/debug/dog"
  96. # print versions of the necessary build tools
  97. @versions:
  98. rustc --version
  99. cargo --version
  100. #---------------#
  101. # documentation #
  102. #---------------#
  103. # render the documentation
  104. @doc:
  105. cargo doc --no-deps --workspace
  106. # build the man pages
  107. @man:
  108. mkdir -p "${CARGO_TARGET_DIR:-target}/man"
  109. pandoc --standalone -f markdown -t man man/dog.1.md > "${CARGO_TARGET_DIR:-target}/man/dog.1"
  110. # build and preview the man page
  111. @man-preview: man
  112. man "${CARGO_TARGET_DIR:-target}/man/dog.1"
  113. #-----------#
  114. # packaging #
  115. #-----------#
  116. # create a distributable package
  117. zip desc exe="dog":
  118. #!/usr/bin/env perl
  119. use Archive::Zip;
  120. -e 'target/release/{{ exe }}' || die 'Binary not built!';
  121. -e 'target/man/dog.1' || die 'Man page not built!';
  122. my $zip = Archive::Zip->new();
  123. $zip->addFile('completions/dog.bash');
  124. $zip->addFile('completions/dog.zsh');
  125. $zip->addFile('completions/dog.fish');
  126. $zip->addFile('target/man/dog.1', 'man/dog.1');
  127. $zip->addFile('target/release/{{ exe }}', 'bin/{{ exe }}');
  128. $zip->writeToFileNamed('dog-{{ desc }}.zip') == AZ_OK || die 'Zip write error!';
  129. system 'unzip -l "dog-{{ desc }}".zip'