MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / daemon_binary

Function daemon_binary

atomic-cli/tests/provenance_rpc_sink.rs:55–111  ·  view source on GitHub ↗

Discover an actual daemon target for the optional external transport tests. The mandatory trait-flow test serves the same handlers in this process.

()

Source from the content-addressed store, hash-verified

53/// Discover an actual daemon target for the optional external transport tests.
54/// The mandatory trait-flow test serves the same handlers in this process.
55fn daemon_binary() -> Option<PathBuf> {
56 let root = reactor_root()?;
57 // A sibling directory named reactor is not proof it contains atomicd.
58 // Cargo also owns the target directory (including CARGO_TARGET_DIR).
59 let output = Command::new("cargo")
60 .args([
61 "metadata",
62 "--format-version",
63 "1",
64 "--no-deps",
65 "--locked",
66 "--offline",
67 "--manifest-path",
68 ])
69 .arg(root.join("Cargo.toml"))
70 .output()
71 .expect("inspect Reactor targets");
72 assert!(
73 output.status.success(),
74 "cannot inspect Reactor targets: {}",
75 String::from_utf8_lossy(&output.stderr)
76 );
77 let metadata: serde_json::Value =
78 serde_json::from_slice(&output.stdout).expect("Cargo metadata JSON");
79 let has_daemon = metadata["packages"]
80 .as_array()
81 .expect("Cargo packages")
82 .iter()
83 .any(|package| {
84 package["targets"]
85 .as_array()
86 .expect("Cargo targets")
87 .iter()
88 .any(|target| {
89 target["name"] == "atomicd"
90 && target["kind"]
91 .as_array()
92 .is_some_and(|kinds| kinds.iter().any(|kind| kind == "bin"))
93 })
94 });
95 if !has_daemon {
96 assert!(
97 std::env::var_os("ATOMIC_REACTOR_ROOT").is_none(),
98 "ATOMIC_REACTOR_ROOT explicitly names a workspace without an atomicd binary target"
99 );
100 return None;
101 }
102 Some(
103 PathBuf::from(
104 metadata["target_directory"]
105 .as_str()
106 .expect("Cargo target directory"),
107 )
108 .join("debug")
109 .join(format!("atomicd{}", std::env::consts::EXE_SUFFIX)),
110 )
111}
112

Calls 4

reactor_rootFunction · 0.85
outputMethod · 0.45
iterMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected