mod common;
use common::sqry_bin;
use assert_cmd::Command;
use predicates::prelude::*;
use std::fs;
use tempfile::TempDir;
fn build_minimal_indexed_repo() -> TempDir {
let dir = TempDir::new().unwrap();
fs::write(
dir.path().join("a.c"),
r"int helper(void) { return 1; }
int caller(void) { return helper(); }
",
)
.unwrap();
Command::new(sqry_bin())
.current_dir(&dir)
.args(["index", "."])
.assert()
.success();
dir
}
#[test]
fn dependency_tree_accepts_relative_file_path() {
let dir = build_minimal_indexed_repo();
Command::new(sqry_bin())
.current_dir(&dir)
.args(["graph", "--path", ".", "dependency-tree", "a.c"])
.assert()
.success();
}
#[test]
fn dependency_tree_accepts_absolute_file_path() {
let dir = build_minimal_indexed_repo();
let abs = dir.path().join("a.c");
Command::new(sqry_bin())
.current_dir(&dir)
.args(["graph", "--path", "."])
.arg("dependency-tree")
.arg(&abs)
.assert()
.success();
}
#[test]
fn dependency_tree_unknown_module_reports_both_lookup_paths() {
let dir = build_minimal_indexed_repo();
Command::new(sqry_bin())
.current_dir(&dir)
.args([
"graph",
"--path",
".",
"dependency-tree",
"nope_not_a_thing",
])
.assert()
.failure()
.stderr(
predicate::str::contains("symbol-name lookup")
.and(predicate::str::contains("file-path lookup")),
);
}