Skip to content

Commit

Permalink
sudo-test: use different tags for docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric committed Mar 27, 2023
1 parent 7c5a0cd commit 0c1ca0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test-framework/sudo-test/src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{

use tempfile::NamedTempFile;

use crate::{Result, SudoUnderTest, BASE_IMAGE};
use crate::{base_image, Result, SudoUnderTest};

pub use self::command::{Child, Command, Output};

Expand Down Expand Up @@ -99,7 +99,7 @@ pub fn build_base_image() -> Result<()> {
let repo_root = repo_root();
let mut cmd = StdCommand::new("docker");

cmd.args(["build", "-t", BASE_IMAGE]);
cmd.args(["build", "-t", base_image()]);

match SudoUnderTest::from_env()? {
SudoUnderTest::Ours => {
Expand Down
10 changes: 8 additions & 2 deletions test-framework/sudo-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ type Result<T> = core::result::Result<T, Error>;

mod docker;

const BASE_IMAGE: &str = env!("CARGO_CRATE_NAME");
fn base_image() -> &'static str {
if is_original_sudo() {
"sudo-test-og"
} else {
"sudo-test-rs"
}
}

/// are we testing the original sudo?
pub fn is_original_sudo() -> bool {
Expand Down Expand Up @@ -172,7 +178,7 @@ impl EnvBuilder {
docker::build_base_image().expect("fatal error: could not build the base Docker image")
});

let container = Container::new(BASE_IMAGE)?;
let container = Container::new(base_image())?;

let (mut usernames, user_ids) = getent_passwd(&container)?;

Expand Down

0 comments on commit 0c1ca0b

Please sign in to comment.