Justfile 4.1 KB

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