Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverted the "kind" field to the previous value. #3668

Merged
merged 8 commits into from
Feb 11, 2017

Conversation

KalitaAlexey
Copy link
Contributor

@KalitaAlexey KalitaAlexey commented Feb 8, 2017

Added a new field named "crate_types".
Fixes #3654
After this PR cargo metadata would output:

{
    "packages": [
        {
            "targets": [
                {
                    "kind": ["lib"],
                    "crate_types": ["lib"]
                },
                {
                    "kind": ["example"],
                    "crate_types": ["staticlib"]
                }
            ]
        }
    ]
}

I have added tests.

Added a new field named "crate_types".
@rust-highfive
Copy link

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

I believe previously kind for something like crate-type = ["rlib", "dylib"] would be ["rlib", "dylib"], right? Could we preserve that part (odd though it may be) as well?

@KalitaAlexey
Copy link
Contributor Author

@alexcrichton,
That wasn't changed.

@KalitaAlexey
Copy link
Contributor Author

I will fix it.

@alexcrichton
Copy link
Member

@KalitaAlexey yes, it was changed. If you make a small example library with two crate-types, metadata prints this

"kind" : [
   "rlib",
   "dylib"
]

@KalitaAlexey
Copy link
Contributor Author

@alexcrichton,
I have tests, which tell you are not right, but I will check it.

@KalitaAlexey
Copy link
Contributor Author

KalitaAlexey commented Feb 9, 2017

@alexcrichton,
Something wrong.
Hm.
I did:

git pull upstream master
cargo test

I got:

failures:

---- finds_author_email stdout ----
        running `D:\Projects\Rust\cargo\target\debug\cargo new foo`
thread 'finds_author_email' panicked at 'assertion failed: contents.contains(r#"authors = ["bar <baz>"]"#)', tests\new.rs:314
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- finds_author_user stdout ----
        running `D:\Projects\Rust\cargo\target\debug\cargo new foo`
thread 'finds_author_user' panicked at 'assertion failed: contents.contains(r#"authors = ["foo"]"#)', tests\new.rs:246

---- finds_author_user_escaped stdout ----
        running `D:\Projects\Rust\cargo\target\debug\cargo new foo`
thread 'finds_author_user_escaped' panicked at 'assertion failed: contents.contains(r#"authors = ["foo \"bar\""]"#)', tests\new.rs:261

---- finds_author_username stdout ----
        running `D:\Projects\Rust\cargo\target\debug\cargo new foo`
thread 'finds_author_username' panicked at 'assertion failed: contents.contains(r#"authors = ["foo"]"#)', tests\new.rs:278

---- finds_git_author stdout ----
        running `D:\Projects\Rust\cargo\target\debug\cargo new foo`
thread 'finds_git_author' panicked at 'assertion failed: contents.contains(r#"authors = ["gitfoo"]"#)', tests\new.rs:362


failures:
    finds_author_email
    finds_author_user
    finds_author_user_escaped
    finds_author_username
    finds_git_author

test result: FAILED. 22 passed; 5 failed; 0 ignored; 0 measured

},
{
"kind": [ "example" ],
"crate_types": [ "rlib", "dylib" ],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcrichton,
The test checks what you asked.

@alexcrichton
Copy link
Member

As I mentioned before, we'll need to preserve the existing stable semantics of cargo metadata (the purpose of this change). To that end the kind entry may need to be an array of crate types actually for libraries. Does that make sense?

@KalitaAlexey
Copy link
Contributor Author

@alexcrichton,
I am sorry, but I can't figure out what you are telling me.

@alexcrichton
Copy link
Member

Currently this PR will emit at most one entry in the array of the kind field, but contrast that with:

cargo +stable new foo
cd foo
cat >> Cargo.toml <<-EOF
[lib]
crate-type = ["lib", "dylib"]
EOF
cargo +stable metadata | json_pp | grep -A 3 kind

That prints:

"kind" : [
   "lib",
   "dylib"
],

@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Collaborator

bors commented Feb 11, 2017

📌 Commit 582bc55 has been approved by alexcrichton

@bors
Copy link
Collaborator

bors commented Feb 11, 2017

⌛ Testing commit 582bc55 with merge 6f1b860...

bors added a commit that referenced this pull request Feb 11, 2017
Reverted the "kind" field to the previous value.

Added a new field named "crate_types".
Fixes #3654
After this PR `cargo metadata` would output:
```json
{
    "packages": [
        {
            "targets": [
                {
                    "kind": ["lib"],
                    "crate_types": ["lib"]
                },
                {
                    "kind": ["example"],
                    "crate_types": ["staticlib"]
                }
            ]
        }
    ]
}
```

I have added tests.
@bors
Copy link
Collaborator

bors commented Feb 11, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 6f1b860 to master...

@bors bors merged commit 582bc55 into rust-lang:master Feb 11, 2017
@ehuss
Copy link
Contributor

ehuss commented Mar 12, 2017

I'm curious, will this get merged to the beta channel/rustc-1.16? I'm not familiar with how rust/cargo releases and branches are handled.

@alexcrichton
Copy link
Member

@ehuss oh is this bug on beta? I thought it was only on nightly?

@ehuss
Copy link
Contributor

ehuss commented Mar 12, 2017

The original commit that added support for examples as libraries (#3556) was added to master around Jan 20. I think the rust-1.16.0 branch was made around Feb 1. This fix was committed to master on Feb 11, after the rust-1.16.0 branch was made. I assume beta is being pulled from the rust-1.16.0 branch.

@alexcrichton
Copy link
Member

@ehuss ah yes I'll backport, thanks for the ping!

bors added a commit that referenced this pull request Mar 13, 2017
[rust-1.16.0] Backport #3668 to rust-1.16.0

This PR backports #3668 which fixes a regression on Rust 1.16.0
@alexcrichton
Copy link
Member

@ehuss backported in #3826

@KalitaAlexey
Copy link
Contributor Author

@alexcrichton,
Will 1.16 be published without the bug?

@alexcrichton
Copy link
Member

Yes

@brson
Copy link
Contributor

brson commented Mar 16, 2017

This is not actually in the 1.16 release as the backport occured after the build.

@ehuss ehuss added this to the 1.17.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"cargo metadata" no longer displays "example" kind if example specifies crate-type
6 participants