[package]
name = "libm-test"
version = "0.1.0"
edition = "2024"
publish = false
license = "MIT OR Apache-2.0"

[dependencies]
anyhow.workspace = true
# This is not directly used but is required so we can enable `gmp-mpfr-sys/force-cross`.
gmp-mpfr-sys = { workspace = true, optional = true }
indicatif.workspace = true
libm = { workspace = true, default-features = true, features = ["unstable-public-internals"] }
libm-macros.workspace = true
musl-math-sys = { workspace = true, optional = true }
paste.workspace = true
rand.workspace = true
rand_chacha.workspace = true
rayon.workspace = true
rug = { workspace = true, optional = true }

# Really dev dependencies, but those can't be optional
criterion = { workspace = true, optional = true }
gungraun = { workspace = true, optional = true }

[target.'cfg(target_family = "wasm")'.dependencies]
getrandom = { workspace = true, features = ["wasm_js"] }
indicatif = { workspace = true, features = ["wasmbind"] }

[build-dependencies]
rand = { workspace = true, optional = true }

[dev-dependencies]
libtest-mimic.workspace = true

[features]
default = ["build-mpfr", "unstable-float"]

# Propagated from libm because this affects which functions we test.
unstable-float = ["libm/unstable-float", "rug?/nightly-float"]

# Generate tests which are random inputs and the outputs are calculated with
# musl libc.
build-mpfr = ["dep:rug", "dep:gmp-mpfr-sys"]

# Build our own musl for testing and benchmarks
build-musl = ["dep:musl-math-sys"]

# Config for wall time benchmarks. Plotters and html_reports bring in extra
# deps so are off by default for CI.
benchmarking-reports = ["walltime", "criterion/plotters", "criterion/html_reports"]
walltime = ["dep:criterion"]

# Enable icount benchmarks (requires gungraun-runner and valgrind locally)
icount = ["dep:gungraun"]

# Run with a reduced set of benchmarks, such as for CI
short-benchmarks = []

[[bench]]
name = "icount"
harness = false
required-features = ["icount"]

[[bench]]
name = "random"
harness = false
required-features = ["walltime"]

[[test]]
# No harness so that we can skip tests at runtime based on env. Prefixed with
# `z` so these tests get run last.
name = "z_extensive"
harness = false

[lints.rust]
# Values from the chared config.rs used by `libm` but not the test crate
unexpected_cfgs = { level = "warn", check-cfg = [
  'cfg(feature, values("arch", "force-soft-floats", "unstable-intrinsics"))',
] }
