Auto merge of #13703 - epage:toml, r=arlosi

test(metadata): Show behavior with TOML-specific types

### What does this PR try to resolve?

The goal is to know if/when these change so we can have a conversation about what to do.

### How should we test and review this PR?

### Additional information
This commit is contained in:
bors 2024-04-04 22:20:15 +00:00
commit a9a0746945

View File

@ -4546,3 +4546,109 @@ fn versionless_packages() {
)
.run();
}
/// Record how TOML-specific types are deserialized by `toml` so we can make sure we know if these change and
/// can have a conversation about what should be done.
#[cargo_test]
fn cargo_metadata_toml_types() {
let p = project()
.file("src/lib.rs", "")
.file(
"Cargo.toml",
"
[package]
name = 'foo'
edition = '2015'
[package.metadata]
offset-datetime = 1979-05-27T07:32:00Z
local-datetime = 1979-05-27T07:32:00
local-date = 1979-05-27
local-time = 1979-05-27
",
)
.build();
p.cargo("metadata")
.with_json(
r#"
{
"packages": [
{
"authors": [],
"categories": [],
"default_run": null,
"name": "foo",
"version": "0.0.0",
"id": "[..]foo#0.0.0",
"keywords": [],
"source": null,
"dependencies": [],
"edition": "2015",
"license": null,
"license_file": null,
"links": null,
"description": null,
"readme": null,
"repository": null,
"rust_version": null,
"homepage": null,
"documentation": null,
"homepage": null,
"documentation": null,
"targets": [
{
"kind": [
"lib"
],
"crate_types": [
"lib"
],
"doc": true,
"doctest": true,
"test": true,
"edition": "2015",
"name": "foo",
"src_path": "[..]/foo/src/lib.rs"
}
],
"features": {},
"manifest_path": "[..]Cargo.toml",
"metadata": {
"local-date": {
"$__toml_private_datetime": "1979-05-27"
},
"local-datetime": {
"$__toml_private_datetime": "1979-05-27T07:32:00"
},
"local-time": {
"$__toml_private_datetime": "1979-05-27"
},
"offset-datetime": {
"$__toml_private_datetime": "1979-05-27T07:32:00Z"
}
},
"publish": []
}
],
"workspace_members": ["path+file:[..]foo#0.0.0"],
"workspace_default_members": ["path+file:[..]foo#0.0.0"],
"resolve": {
"nodes": [
{
"dependencies": [],
"deps": [],
"features": [],
"id": "path+file:[..]foo#0.0.0"
}
],
"root": "path+file:[..]foo#0.0.0"
},
"target_directory": "[..]foo/target",
"version": 1,
"workspace_root": "[..]/foo",
"metadata": null
}"#,
)
.run();
}