Cargo --features option doesn't take effect

It seems like passing --features argument in cargo doesn't take effect.

cargo test --features "with-sqlite"

would not run any of the feature specific tests.

However, doing

cargo test --all-features

would run the test specific features.

Cargo.toml

 ...
[dependencies]
sqlite = {version = "0.23.9", optional = true}
r2d2-sqlite3 = {version = "0.1.0", optional = true}

[features]
with-sqlite = ["sqlite","r2d2-sqlite3"]
....

Does anyone have the same problem?

How are your tests #[cfg()]'d?

in lib.rs:

cfg_if! {if #[cfg(feature = "with-sqlite")]{
    extern crate r2d2_sqlite3;
    extern crate sqlite as sqlite3;
    mod sq;
}}

in sq.rs:

#[cfg(test)]
mod test{

    #[test]
    fn simple(){
        assert!(1==2);
    }
}

Not even a test fail.

Alright, I think I already get it. You have to be in the crate's folder when you are testing it with specific feature.
that is:

cd orm/
cargo test --features "with-sqlite"

However, when you are in the root workspace (the parent folder of the crate), doing it:
cargo test --features "with-sqlite"
would not take effect.

Trying out
cargo test -p orm --features "with-sqlite"
won't work either.

But then enabling all the features, would test out all crates that are member of the workspace.
cargo test --all-features

I think the correct behavior of cargo should be that doing
cargo test -p orm --features "with-sqlite"
should work.
just like cargo -p app1 run would work.