@@ -67,9 +67,11 @@ async fn test_check_specific_tool() {
6767 // Check a specific tool (OpenTofu)
6868 let output = container. exec ( & [ "dependency-installer" , "check" , "--tool" , "opentofu" ] ) ;
6969
70- // The output contains the status line with the checkmark/X symbol
70+ // The output contains "OpenTofu: not installed" in the status line
71+ // We check for the plain text version since the ✗ symbol may not be present
72+ // in all terminal environments or when output is redirected
7173 assert ! (
72- output. contains( "✗ OpenTofu: not installed" ) || output . contains ( " OpenTofu: not installed") ,
74+ output. contains( "OpenTofu: not installed" ) ,
7375 "Expected OpenTofu to be reported as not installed, got: {}" ,
7476 output
7577 ) ;
@@ -149,16 +151,34 @@ async fn test_verbose_output() {
149151///
150152/// This function assumes the binary was built before running tests.
151153/// Run `cargo build --bin dependency-installer` before running these tests.
154+ ///
155+ /// # Implementation Note
156+ ///
157+ /// We use CARGO_MANIFEST_DIR and navigate up to the workspace root, then into
158+ /// the target directory. This works because:
159+ /// 1. CARGO_MANIFEST_DIR points to packages/dependency-installer
160+ /// 2. The workspace root is two directories up
161+ /// 3. The target directory is in the workspace root
162+ ///
163+ /// Alternative approaches considered:
164+ /// - CARGO_TARGET_DIR: Not always set
165+ /// - OUT_DIR: Points to build script output, not target/debug
166+ /// - Searching for target dir: Too expensive
152167fn get_binary_path ( ) -> PathBuf {
153- // Get the workspace root directory
154- let mut path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
155-
156- // Navigate to workspace target directory
157- path. pop ( ) ; // packages
158- path. pop ( ) ; // repository root
159- path. push ( "target" ) ;
160- path. push ( "debug" ) ;
161- path. push ( "dependency-installer" ) ;
168+ // Get the package manifest directory (packages/dependency-installer)
169+ let manifest_dir = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
170+
171+ // Navigate to workspace root (two levels up from packages/dependency-installer)
172+ let workspace_root = manifest_dir
173+ . parent ( ) // packages/
174+ . and_then ( |p| p. parent ( ) ) // workspace root
175+ . expect ( "Failed to find workspace root" ) ;
176+
177+ // Build path to the binary in target/debug
178+ let path = workspace_root
179+ . join ( "target" )
180+ . join ( "debug" )
181+ . join ( "dependency-installer" ) ;
162182
163183 assert ! (
164184 path. exists( ) ,
0 commit comments