-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathjustfile
114 lines (94 loc) · 3.53 KB
/
justfile
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
alias t := test
alias ut:= unit-test
alias it := integration-test
unit-test: unit-test-jni-1_8 unit-test-jni-1_6
unit-test-jni-1_6:
cargo test --features jni_1_6
unit-test-jni-1_8:
cargo test --features jni_1_8
integration-test: integration-test-jni-1_8 integration-test-jni-1_6
integration-test-jni-1_6:
(cd test-crates && cargo test --features jni_1_6)
integration-test-jni-1_8:
(cd test-crates && cargo test --features jni_1_8)
build-rs-tests:
(cd duchess-build-rs && cargo test)
test: build-rs-tests unit-test integration-test
test-jni-1_8: unit-test-jni-1_8 integration-test-jni-1_8
test-jni-1_6: unit-test-jni-1_6 integration-test-jni-1_6
coverage-tools:
rustup component add llvm-tools
cargo install cargo-binutils
cargo install rustfilt
test_coverage := "test-coverage"
coverage_file := "duchess-coverage-%p-%10m.profraw"
coverage-clean:
#!/usr/bin/env bash
set -euxo pipefail
target={{justfile_directory()}}/target
coverage_dir=$target/{{test_coverage}}
rm -rf $coverage_dir
rm -rf $target/ui-coverage-report
coverage-unit-tests:
#!/usr/bin/env bash
set -euxo pipefail
target={{justfile_directory()}}/target
coverage_dir=$target/{{test_coverage}}
(RUSTFLAGS="-C instrument-coverage" LLVM_PROFILE_FILE=$coverage_dir/{{coverage_file}} cargo test) || true
coverage-ui-test:
#!/usr/bin/env bash
set -euxo pipefail
target={{justfile_directory()}}/target
coverage_dir=$target/{{test_coverage}}
(cd test-crates && RUSTFLAGS="-C instrument-coverage" LLVM_PROFILE_FILE=$coverage_dir/duchess-%p-%10m.profraw cargo test) || true
coverage-show:
#!/usr/bin/env bash
set -euxo pipefail
target={{justfile_directory()}}/target
coverage_dir=$target/{{test_coverage}}
# For some reason, the LLVM tools are also emitting profiling data, suppress this.
export LLVM_PROFILE_FILE=/dev/null
echo "Found profile data from $(ls $coverage_dir/duchess*.profraw | wc -l) profile runs"
rust-profdata merge -sparse $coverage_dir/duchess*.profraw -o $coverage_dir/test-crates.profdata
# Determine the operating system
OS="$(uname)"
if [[ "$OS" == "Darwin" ]]; then
FILE_EXTENSION="dylib"
elif [[ "$OS" == "Linux" ]]; then
FILE_EXTENSION="so"
else
echo "Unsupported OS"
exit 1
fi
rust-cov show --instr-profile $coverage_dir/test-crates.profdata -Xdemangler=rustfilt \
--format=html \
--output-dir $target/ui-coverage-report \
--object test-crates/target/tests/rust-to-java/examples/greeting \
--object test-crates/target/tests/rust-to-java/exceptions \
$( \
for file in \
$( \
RUSTFLAGS="-C instrument-coverage" \
LLVM_PROFILE_FILE="$target/ignored-%p-%10m.profraw" \
cargo test --tests --no-run --message-format=json \
| jq -r "select(.profile.test == true) | .filenames[]" \
| grep -v dSYM - \
); \
do \
printf "%s %s " -object $file; \
done \
) \
--object $target/debug/deps/libduchess_macro-*.$FILE_EXTENSION \
--show-instantiations=false \
--sources {{justfile_directory()}}/src \
--sources {{justfile_directory()}}/macro
# Allow CI to suppress autoopening the report
if [ -z "${NO_OPEN+x}" ]; then
open $target/ui-coverage-report/index.html
fi
coverage: coverage-clean coverage-unit-tests coverage-ui-test coverage-show
publish:
git describe --exact-match --tags HEAD || (echo "You must publish a tagged release. Checkout the tag before publishing" && exit 1)
(cd duchess-reflect && cargo publish)
cd macro && cargo publish
cargo publish