Repository: dtolnay/cargo-expand (language: rust)

Issue:
"cargo expand --lib --tests" ignore dev dependencies
`cargo expand --lib --tests` can't resolve extern crates that are dev-dependencies.  dev-dependencies do correctly get resolved when doing `cargo expand --test XXX`, though.  It's as if cargo-expand ignores them whenever you use `--lib`.  Steps to reproduce:

Cargo.toml:
```toml
[package]
name = "cargo_expand_dev_dependencies"
version = "0.1.0"
edition = "2018"

[dev-dependencies]
lazy_static = "1.0"
```
src/lib.rs
```rust
#[cfg(test)]
lazy_static::lazy_static! {
    static ref FOO: u32 = 5u32;
}
```
Output:
```
> cargo expand --lib --tests
    Checking cargo_expand_dev_dependencies v0.1.0 (/tmp/cargo_expand_dev_dependencies)
error[E0433]: failed to resolve: use of undeclared type or module `lazy_static`
 --> src/lib.rs:2:1
  |
2 | lazy_static::lazy_static! {
  | ^^^^^^^^^^^ use of undeclared type or module `lazy_static`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.
error: Could not compile `cargo_expand_dev_dependencies`.
To learn more, run the command again with --verbose.

#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
#[main]
pub fn main() -> () {
    extern crate test as test;
    test::test_main_static(&[])
}
```
```


Discussion / hints:

Fix patch:
diff --git a/src/main.rs b/src/main.rs
index ee76365..c72bfde 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -214,7 +214,12 @@ fn apply_args(cmd: &mut Command, args: &Args, outfile: &Path) {
     let mut line = Line::new("cargo");
 
     line.arg("rustc");
-    line.arg("--profile=check");
+
+    if args.tests && args.test.is_none() {
+        line.arg("--profile=test");
+    } else {
+        line.arg("--profile=check");
+    }
 
     if let Some(features) = &args.features {
         line.arg("--features");
@@ -299,10 +304,6 @@ fn apply_args(cmd: &mut Command, args: &Args, outfile: &Path) {
 
     line.arg("--");
 
-    if args.tests && args.test.is_none() {
-        line.arg("--test");
-    }
-
     line.arg("-o");
     line.arg(outfile);
     line.arg("-Zunstable-options");


Test patch: