File: tests-missing-data.patch

package info (click to toggle)
rust-cargo-metadata 0.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 312 kB
  • sloc: makefile: 2
file content (93 lines) | stat: -rw-r--r-- 3,581 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
diff --git a/tests/selftest.rs b/tests/selftest.rs
index e1658bd..bde4f1f 100644
--- a/tests/selftest.rs
+++ b/tests/selftest.rs
@@ -127,8 +127,11 @@ fn cargo_path() {
 #[test]
 fn metadata_deps() {
     std::env::set_var("CARGO_PROFILE", "3");
+    let dir = tempfile::tempdir().unwrap();
+    let path = dir.path().join("Cargo.toml");
+    std::fs::copy("Cargo.toml", &path).unwrap();
     let metadata = MetadataCommand::new()
-        .manifest_path("Cargo.toml")
+        .manifest_path(path)
         .exec()
         .unwrap();
     let this_id = metadata
@@ -171,8 +174,11 @@ fn metadata_deps() {
 
 #[test]
 fn workspace_default_packages() {
+    let dir = tempfile::tempdir().unwrap();
+    let path = dir.path().join("Cargo.toml");
+    std::fs::copy("Cargo.toml", &path).unwrap();
     let metadata = MetadataCommand::new()
-        .manifest_path("Cargo.toml")
+        .manifest_path(path)
         .exec()
         .unwrap();
     let workspace_packages = metadata.workspace_packages();
diff --git a/tests/test_samples.rs b/tests/test_samples.rs
index 95a8ab8..18ac173 100644
--- a/tests/test_samples.rs
+++ b/tests/test_samples.rs
@@ -179,6 +179,7 @@ struct TestObject {
 }
 
 #[test]
+#[cfg(any())]
 fn all_the_fields() {
     // All the fields currently generated as of 1.60. This tries to exercise as
     // much as possible.
@@ -569,8 +570,13 @@ fn alt_registry() {
 
 #[test]
 fn current_dir() {
+    const manifest: &str = "[package]\nname = 'namedep'\n[lib]\nname = 'different_name'";
+    let dir = tempfile::tempdir().unwrap();
+    std::fs::create_dir(dir.path().join("src")).unwrap();
+    std::fs::write(dir.path().join("Cargo.toml"), manifest).unwrap();
+    std::fs::write(dir.path().join("src").join("lib.rs"), "").unwrap();
     let meta = MetadataCommand::new()
-        .current_dir("tests/all/namedep")
+        .current_dir(dir.path())
         .exec()
         .unwrap();
     let namedep = meta
@@ -603,6 +609,7 @@ Evil proc macro was here!
 }
 
 #[test]
+#[cfg(any())]
 fn advanced_feature_configuration() {
     fn build_features<F: FnOnce(&mut MetadataCommand) -> &mut MetadataCommand>(
         func: F,
@@ -682,15 +689,25 @@ fn depkind_to_string() {
 
 #[test]
 fn basic_workspace_root_package_exists() {
+    const root_manifest: &str = "[package]\nname = 'ex_bin'\n[dependencies]\nex_lib = { path = './ex_lib' }\n[workspace]";
+    const ex_lib_manifest: &str = "[package]\nname = 'ex_lib'";
+    let dir = tempfile::tempdir().unwrap();
+    std::fs::create_dir(dir.path().join("src")).unwrap();
+    std::fs::create_dir(dir.path().join("ex_lib")).unwrap();
+    std::fs::create_dir(dir.path().join("ex_lib").join("src")).unwrap();
+    std::fs::write(dir.path().join("Cargo.toml"), root_manifest).unwrap();
+    std::fs::write(dir.path().join("ex_lib").join("Cargo.toml"), ex_lib_manifest).unwrap();
+    std::fs::write(dir.path().join("src").join("lib.rs"), "").unwrap();
+    std::fs::write(dir.path().join("ex_lib").join("src").join("lib.rs"), "").unwrap();
     // First try with dependencies
     let meta = MetadataCommand::new()
-        .manifest_path("tests/basic_workspace/Cargo.toml")
+        .manifest_path(dir.path().join("Cargo.toml"))
         .exec()
         .unwrap();
     assert_eq!(meta.root_package().unwrap().name.as_str(), "ex_bin");
     // Now with no_deps, it should still work exactly the same
     let meta = MetadataCommand::new()
-        .manifest_path("tests/basic_workspace/Cargo.toml")
+        .manifest_path(dir.path().join("Cargo.toml"))
         .no_deps()
         .exec()
         .unwrap();