add test for many features
and fix issue compiling tor-rtcompat with on ssl runtime
This commit is contained in:
parent
dbf4765832
commit
53016a005b
|
@ -42,6 +42,7 @@ rust-checks:
|
|||
stage: build
|
||||
image: rust:latest
|
||||
script:
|
||||
- apt-get update && apt-get install -y python3-toml python-is-python3
|
||||
- rustup show
|
||||
- rustup component add rustfmt
|
||||
- ./maint/via-cargo-install-in-ci cargo-audit cargo-sort cargo-license
|
||||
|
@ -50,6 +51,7 @@ rust-checks:
|
|||
- ./maint/cargo_audit
|
||||
- ./maint/cargo_sort
|
||||
- ./maint/check_tree
|
||||
- ./maint/matrix_test
|
||||
cache:
|
||||
paths:
|
||||
- cargo-audit
|
||||
|
|
|
@ -63,9 +63,9 @@ pub use timer::{SleepProviderExt, Timeout, TimeoutError};
|
|||
pub mod tls {
|
||||
pub use crate::traits::{CertifiedConn, TlsConnector};
|
||||
|
||||
#[cfg(feature = "native-tls")]
|
||||
#[cfg(all(feature = "native-tls", any(feature = "tokio", feature = "async-std")))]
|
||||
pub use crate::impls::native_tls::NativeTlsProvider;
|
||||
#[cfg(feature = "rustls")]
|
||||
#[cfg(all(feature = "rustls", any(feature = "tokio", feature = "async-std")))]
|
||||
pub use crate::impls::rustls::RustlsProvider;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import toml.decoder
|
||||
import sys
|
||||
import os.path
|
||||
import os
|
||||
import list_crates
|
||||
from subprocess import run
|
||||
|
||||
TOPDIR = os.path.split(os.path.dirname(sys.argv[0]))[0]
|
||||
os.chdir(TOPDIR)
|
||||
CRATEDIR = os.path.join(TOPDIR, 'crates')
|
||||
|
||||
# some tests don't compile on every combination 😐
|
||||
# also test is way slower than check
|
||||
KEYWORD = "check"
|
||||
|
||||
supplementary_targets = dict()
|
||||
|
||||
def combination(*args):
|
||||
res = None
|
||||
for featureset in args:
|
||||
powerset = [[]]
|
||||
for feature in featureset:
|
||||
powerset.extend([combination + [feature] for combination in powerset])
|
||||
# remove empty set
|
||||
powerset.pop(0)
|
||||
if res is None:
|
||||
res = powerset
|
||||
else:
|
||||
new_res = []
|
||||
for prev_feat in res:
|
||||
for new_feat in powerset:
|
||||
new_res.append(prev_feat + new_feat)
|
||||
res = new_res
|
||||
return res
|
||||
|
||||
supplementary_targets["tor-rtcompat"] = combination(["async-std", "tokio", "native-tls", "rustls"])
|
||||
supplementary_targets["arti-client"] = combination(["async-std", "tokio", "native-tls", "rustls"])
|
||||
supplementary_targets["arti"] = combination(["async-std", "tokio"], ["native-tls", "rustls"])
|
||||
|
||||
def take(dic, key):
|
||||
if key in dic:
|
||||
res = dic.get(key)
|
||||
del(dic[key])
|
||||
return res
|
||||
return None
|
||||
|
||||
def test_crate_config(crate, features, allow_empty=False):
|
||||
if features is None:
|
||||
return
|
||||
if len(features) == 0 and not allow_empty:
|
||||
return
|
||||
features = ",".join(features)
|
||||
args = ["cargo", KEYWORD, "-p", crate, "--no-default-features", "--features", features]
|
||||
p = run(args)
|
||||
if p.returncode != 0:
|
||||
raise Exception("Failed to test '" + crate + "' with features '" + features + "'")
|
||||
|
||||
def test_crate(crate):
|
||||
if crate in ['fs-mistrust', 'tor-config']:
|
||||
# these tests do not pass as of now. Skipping them.
|
||||
return
|
||||
|
||||
crate_path = os.path.join(CRATEDIR, crate)
|
||||
toml_path = os.path.join(crate_path, 'Cargo.toml')
|
||||
t = toml.decoder.load(toml_path)
|
||||
features = t.get('features') or {}
|
||||
|
||||
# remove testing features, it makes little sens to test them
|
||||
take(features, 'testing')
|
||||
|
||||
default = sorted(take(features, 'default') or [])
|
||||
full = sorted(take(features, 'full') or [])
|
||||
all_features = sorted([feat for feat in features.keys()])
|
||||
|
||||
# no features; don't test if it would already be tested by normal tests
|
||||
if len(features) != 0:
|
||||
# arti does not work: it requires an executor
|
||||
if not crate in ['arti']:
|
||||
test_crate_config(crate, [], True)
|
||||
# default
|
||||
test_crate_config(crate, default)
|
||||
# full
|
||||
test_crate_config(crate, full)
|
||||
# all
|
||||
test_crate_config(crate, all_features)
|
||||
|
||||
for combination in supplementary_targets.get(crate, []):
|
||||
test_crate_config(crate, combination)
|
||||
# TODO test random combination?
|
||||
|
||||
def main():
|
||||
for crate in list_crates.crate_list():
|
||||
test_crate(crate)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue