| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# This is a script that attempts to *approximately* exhaustively run the test |
| 4 |
# suite for regex-automata. The main reason for why 'cargo test' isn't enough |
| 5 |
# is because of crate features. regex-automata has a ton of them. This script |
| 6 |
# tests many of those feature combinations (although not all) to try to get |
| 7 |
# decent coverage in a finite amount of time. |
| 8 |
|
| 9 |
set -e |
| 10 |
|
| 11 |
# cd to the directory containing this crate's Cargo.toml so that we don't need |
| 12 |
# to pass --manifest-path to every `cargo` command. |
| 13 |
cd "$(dirname "$0")" |
| 14 |
|
| 15 |
echo "===== ALL FEATURES TEST ===" |
| 16 |
cargo test --all-features |
| 17 |
|
| 18 |
# Man I don't *want* to have this many crate features, but... I really want |
| 19 |
# folks to be able to slim the crate down to just the things they want. But |
| 20 |
# the main downside is that I just can't feasibly test every combination of |
| 21 |
# features because there are too many of them. Sad, but I'm not sure if there |
| 22 |
# is a better alternative. |
| 23 |
features=( |
| 24 |
"" |
| 25 |
"unicode-word-boundary" |
| 26 |
"unicode-word-boundary,syntax,unicode-perl" |
| 27 |
"unicode-word-boundary,syntax,dfa-build" |
| 28 |
"nfa" |
| 29 |
"dfa" |
| 30 |
"hybrid" |
| 31 |
"nfa,dfa" |
| 32 |
"nfa,hybrid" |
| 33 |
"dfa,hybrid" |
| 34 |
"dfa-onepass" |
| 35 |
"nfa-pikevm" |
| 36 |
"nfa-backtrack" |
| 37 |
"std" |
| 38 |
"alloc" |
| 39 |
"syntax" |
| 40 |
"syntax,nfa-pikevm" |
| 41 |
"syntax,hybrid" |
| 42 |
"perf-literal-substring" |
| 43 |
"perf-literal-multisubstring" |
| 44 |
"meta" |
| 45 |
"meta,nfa-backtrack" |
| 46 |
"meta,hybrid" |
| 47 |
"meta,dfa-build" |
| 48 |
"meta,dfa-onepass" |
| 49 |
"meta,nfa,dfa,hybrid,nfa-backtrack" |
| 50 |
"meta,nfa,dfa,hybrid,nfa-backtrack,perf-literal-substring" |
| 51 |
"meta,nfa,dfa,hybrid,nfa-backtrack,perf-literal-multisubstring" |
| 52 |
) |
| 53 |
for f in "${features[@]}"; do |
| 54 |
echo "===== LIB FEATURES: $f ===" |
| 55 |
# It's actually important to do a standard 'cargo build' in addition to a |
| 56 |
# 'cargo test'. In particular, in the latter case, the dev-dependencies may |
| 57 |
# wind up enabling features in dependencies (like memchr) that make it look |
| 58 |
# like everything is well, but actually isn't. For example, the 'regex-test' |
| 59 |
# dev-dependency uses 'bstr' and enables its 'std' feature, which in turn |
| 60 |
# unconditionally enables 'memchr's 'std' feature. Since we're specifically |
| 61 |
# looking to test that certain feature combinations work as expected, this |
| 62 |
# can lead to things testing okay, but would actually fail to build. Yikes. |
| 63 |
cargo build --no-default-features --lib --features "$f" |
| 64 |
cargo test --no-default-features --lib --features "$f" |
| 65 |
done |
| 66 |
|
| 67 |
# We can also run the integration test suite on stripped down features too. |
| 68 |
# But the test suite doesn't do well with things like 'std' and 'unicode' |
| 69 |
# disabled, so we always enable them. |
| 70 |
features=( |
| 71 |
"std,unicode,syntax,nfa-pikevm" |
| 72 |
"std,unicode,syntax,nfa-backtrack" |
| 73 |
"std,unicode,syntax,hybrid" |
| 74 |
"std,unicode,syntax,dfa-onepass" |
| 75 |
"std,unicode,syntax,dfa-search" |
| 76 |
"std,unicode,syntax,dfa-build" |
| 77 |
"std,unicode,meta" |
| 78 |
# This one is a little tricky because it causes the backtracker to get used |
| 79 |
# in more instances and results in failing tests for the 'earliest' tests. |
| 80 |
# The actual results are semantically consistent with the API guarantee |
| 81 |
# (the backtracker tends to report greater offsets because it isn't an FSM), |
| 82 |
# but our tests are less flexible than the API guarantee and demand offsets |
| 83 |
# reported by FSM regex engines. (Which is... all of them except for the |
| 84 |
# backtracker.) |
| 85 |
# "std,unicode,meta,nfa-backtrack" |
| 86 |
"std,unicode,meta,hybrid" |
| 87 |
"std,unicode,meta,dfa-onepass" |
| 88 |
"std,unicode,meta,dfa-build" |
| 89 |
"std,unicode,meta,nfa,dfa-onepass,hybrid" |
| 90 |
) |
| 91 |
for f in "${features[@]}"; do |
| 92 |
echo "===== INTEGRATION FEATURES: $f ===" |
| 93 |
cargo build --no-default-features --lib --features "$f" |
| 94 |
cargo test --no-default-features --test integration --features "$f" |
| 95 |
done |