Cargo has an issue (rust-lang/cargo#2305) with a proposed fix (rust-lang/cargo#2469), but it unfortunately can't land because the compiler currently considers --test and --cfg test synonymous.
I'm... surprised by this behavior, and I'd expect --cfg test to only pass the test cfg.