/tests/testsuite/unit_graph.rs

https://gitlab.com/frewsxcv/cargo · Rust · 233 lines · 227 code · 5 blank · 1 comment · 0 complexity · dbdb391f20599b4ade74b47566fc3ec8 MD5 · raw file

  1. //! Tests for --unit-graph option.
  2. use cargo_test_support::project;
  3. use cargo_test_support::registry::Package;
  4. #[cargo_test]
  5. fn gated() {
  6. let p = project().file("src/lib.rs", "").build();
  7. p.cargo("build --unit-graph")
  8. .with_status(101)
  9. .with_stderr(
  10. "\
  11. [ERROR] the `--unit-graph` flag is unstable[..]
  12. See [..]
  13. See [..]
  14. ",
  15. )
  16. .run();
  17. }
  18. #[cargo_test]
  19. fn simple() {
  20. Package::new("a", "1.0.0")
  21. .dep("b", "1.0")
  22. .feature("feata", &["b/featb"])
  23. .publish();
  24. Package::new("b", "1.0.0")
  25. .dep("c", "1.0")
  26. .feature("featb", &["c/featc"])
  27. .publish();
  28. Package::new("c", "1.0.0").feature("featc", &[]).publish();
  29. let p = project()
  30. .file(
  31. "Cargo.toml",
  32. r#"
  33. [package]
  34. name = "foo"
  35. version = "0.1.0"
  36. [dependencies]
  37. a = "1.0"
  38. "#,
  39. )
  40. .file("src/lib.rs", "")
  41. .build();
  42. p.cargo("build --features a/feata --unit-graph -Zunstable-options")
  43. .masquerade_as_nightly_cargo()
  44. .with_json(
  45. r#"{
  46. "roots": [
  47. 3
  48. ],
  49. "units": [
  50. {
  51. "dependencies": [
  52. {
  53. "extern_crate_name": "b",
  54. "index": 1,
  55. "noprelude": false,
  56. "public": false
  57. }
  58. ],
  59. "features": [
  60. "feata"
  61. ],
  62. "mode": "build",
  63. "pkg_id": "a 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  64. "platform": null,
  65. "profile": {
  66. "codegen_backend": null,
  67. "codegen_units": null,
  68. "debug_assertions": true,
  69. "debuginfo": 2,
  70. "incremental": false,
  71. "lto": "false",
  72. "name": "dev",
  73. "opt_level": "0",
  74. "overflow_checks": true,
  75. "panic": "unwind",
  76. "rpath": false,
  77. "split_debuginfo": "{...}",
  78. "strip": "none"
  79. },
  80. "target": {
  81. "crate_types": [
  82. "lib"
  83. ],
  84. "doc": true,
  85. "doctest": true,
  86. "edition": "2015",
  87. "kind": [
  88. "lib"
  89. ],
  90. "name": "a",
  91. "src_path": "[..]/a-1.0.0/src/lib.rs",
  92. "test": true
  93. }
  94. },
  95. {
  96. "dependencies": [
  97. {
  98. "extern_crate_name": "c",
  99. "index": 2,
  100. "noprelude": false,
  101. "public": false
  102. }
  103. ],
  104. "features": [
  105. "featb"
  106. ],
  107. "mode": "build",
  108. "pkg_id": "b 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  109. "platform": null,
  110. "profile": {
  111. "codegen_backend": null,
  112. "codegen_units": null,
  113. "debug_assertions": true,
  114. "debuginfo": 2,
  115. "incremental": false,
  116. "lto": "false",
  117. "name": "dev",
  118. "opt_level": "0",
  119. "overflow_checks": true,
  120. "panic": "unwind",
  121. "rpath": false,
  122. "split_debuginfo": "{...}",
  123. "strip": "none"
  124. },
  125. "target": {
  126. "crate_types": [
  127. "lib"
  128. ],
  129. "doc": true,
  130. "doctest": true,
  131. "edition": "2015",
  132. "kind": [
  133. "lib"
  134. ],
  135. "name": "b",
  136. "src_path": "[..]/b-1.0.0/src/lib.rs",
  137. "test": true
  138. }
  139. },
  140. {
  141. "dependencies": [],
  142. "features": [
  143. "featc"
  144. ],
  145. "mode": "build",
  146. "pkg_id": "c 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  147. "platform": null,
  148. "profile": {
  149. "codegen_backend": null,
  150. "codegen_units": null,
  151. "debug_assertions": true,
  152. "debuginfo": 2,
  153. "incremental": false,
  154. "lto": "false",
  155. "name": "dev",
  156. "opt_level": "0",
  157. "overflow_checks": true,
  158. "panic": "unwind",
  159. "rpath": false,
  160. "split_debuginfo": "{...}",
  161. "strip": "none"
  162. },
  163. "target": {
  164. "crate_types": [
  165. "lib"
  166. ],
  167. "doc": true,
  168. "doctest": true,
  169. "edition": "2015",
  170. "kind": [
  171. "lib"
  172. ],
  173. "name": "c",
  174. "src_path": "[..]/c-1.0.0/src/lib.rs",
  175. "test": true
  176. }
  177. },
  178. {
  179. "dependencies": [
  180. {
  181. "extern_crate_name": "a",
  182. "index": 0,
  183. "noprelude": false,
  184. "public": false
  185. }
  186. ],
  187. "features": [],
  188. "mode": "build",
  189. "pkg_id": "foo 0.1.0 (path+file://[..]/foo)",
  190. "platform": null,
  191. "profile": {
  192. "codegen_backend": null,
  193. "codegen_units": null,
  194. "debug_assertions": true,
  195. "debuginfo": 2,
  196. "incremental": false,
  197. "lto": "false",
  198. "name": "dev",
  199. "opt_level": "0",
  200. "overflow_checks": true,
  201. "panic": "unwind",
  202. "rpath": false,
  203. "split_debuginfo": "{...}",
  204. "strip": "none"
  205. },
  206. "target": {
  207. "crate_types": [
  208. "lib"
  209. ],
  210. "doc": true,
  211. "doctest": true,
  212. "edition": "2015",
  213. "kind": [
  214. "lib"
  215. ],
  216. "name": "foo",
  217. "src_path": "[..]/foo/src/lib.rs",
  218. "test": true
  219. }
  220. }
  221. ],
  222. "version": 1
  223. }
  224. "#,
  225. )
  226. .run();
  227. }