`debug = true` does not generate debug info for test build

I have tests in main.rs which uses some libraries.
I put debug = true in [profile.release] and compiled the crate:
cargo build --release --tests --target=thumbv8m.main-none-eabi -Z build-std=core,alloc

If I examine the test binary generated in target/thumbv8m.main-none-eabi/release/deps, it does not seem to generate debug info for main.rs, although it is generated for the libraries. But putting -g in rustflags does generate debug info for main.rs

I wonder if it is a bug, or an intended behavior.

Note that I'm using thumbv8m.main-none-eabi target, and using custom_test_frameworks so the above may not be the general case.