Skip to content

Commit

Permalink
no wonder why the examples gha test was failing. cargo pgx test wasn'…
Browse files Browse the repository at this point in the history
…t updated to the new PgConfig stuff
  • Loading branch information
eeeebbbbrrrr committed Nov 16, 2020
1 parent 27c1670 commit 666998a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
6 changes: 5 additions & 1 deletion cargo-pgx/src/commands/test.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright 2020 ZomboDB, LLC <[email protected]>. All rights reserved. Use of this source code is
// governed by the MIT license that can be found in the LICENSE file.

use pgx_utils::pg_config::PgConfig;
use pgx_utils::{exit_with_error, get_target_dir, handle_result};
use std::process::{Command, Stdio};

pub fn test_extension(major_version: u16, is_release: bool) {
pub fn test_extension(pg_config: &PgConfig, is_release: bool) -> Result<(), std::io::Error> {
let major_version = pg_config.major_version()?;
let target_dir = get_target_dir();

let mut command = Command::new("cargo");
Expand Down Expand Up @@ -32,4 +34,6 @@ pub fn test_extension(major_version: u16, is_release: bool) {
if !status.success() {
exit_with_error!("cargo pgx test failed with status = {:?}", status.code())
}

Ok(())
}
17 changes: 4 additions & 13 deletions cargo-pgx/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ fn do_it() -> std::result::Result<(), std::io::Error> {
connect_psql(Pgx::from_config()?.get(pgver)?, &dbname)
}
("test", Some(test)) => {
let pgver = test.value_of("pg_version").unwrap_or("all");
let is_release = test.is_present("release");
for major_version in make_pg_major_version(pgver) {
test_extension(*major_version, is_release);
let pgver = test.value_of("pg_version").unwrap_or("all");
let pgx = Pgx::from_config()?;
for pg_config in pgx.iter(PgConfigSelector::new(pgver)) {
test_extension(pg_config?, is_release)?
}
Ok(())
}
Expand Down Expand Up @@ -202,13 +203,3 @@ fn validate_extension_name(extname: &str) {
}
}
}

fn make_pg_major_version(version_string: &str) -> &'static [u16] {
match version_string {
"all" => &[10, 11, 12],
"pg10" => &[10],
"pg11" => &[11],
"pg12" => &[12],
_ => exit_with_error!("unrecognized Postgres version: {}", version_string),
}
}

0 comments on commit 666998a

Please sign in to comment.