Skip to content

Commit

Permalink
cli(trunk-test): generalize extension name during Makefile searching (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vrmiguel authored Nov 28, 2023
1 parent 77477f8 commit c5a8408
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pg-trunk"
version = "0.11.8"
version = "0.11.9"
edition = "2021"
authors = ["Steven Miller", "Ian Stanton", "Vinícius Miguel"]
description = "A package manager for PostgreSQL extensions"
Expand Down
6 changes: 5 additions & 1 deletion cli/src/commands/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ fn prepare_sharedir_file<'p>(
pub async fn locate_makefile(
docker: &Docker,
container_id: &str,
extension_name: &str,
) -> anyhow::Result<Option<PathBuf>> {
let stdout = exec_in_container(
docker,
Expand All @@ -639,7 +640,10 @@ pub async fn locate_makefile(
//
// The idea here is that the "root" Makefile of a project would
// therefore be the Makefile with the smallest path
let maybe_makefile = stdout.lines().filter(|line| line.contains("cube")).min();
let maybe_makefile = stdout
.lines()
.filter(|line| line.contains(extension_name))
.min();

let maybe_makefile = maybe_makefile.or_else(|| stdout.lines().min());

Expand Down
11 changes: 8 additions & 3 deletions cli/src/commands/generic_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ pub async fn build_generic(
.await?;

if should_test {
let extension_name = extension_name.as_deref().unwrap_or(name);
// Check if there are extensions to run
run_tests(&docker, &temp_container.id).await?;
run_tests(&docker, &temp_container.id, extension_name).await?;
}

println!("Determining installation files...");
Expand Down Expand Up @@ -161,8 +162,12 @@ pub async fn build_generic(
Ok(())
}

async fn run_tests(docker: &Docker, container_id: &str) -> anyhow::Result<()> {
let Some(project_dir) = locate_makefile(docker, container_id).await? else {
async fn run_tests(
docker: &Docker,
container_id: &str,
extension_name: &str,
) -> anyhow::Result<()> {
let Some(project_dir) = locate_makefile(docker, container_id, extension_name).await? else {
println!("Makefile not found!");
return Ok(());
};
Expand Down

0 comments on commit c5a8408

Please sign in to comment.