Skip to content

Commit

Permalink
Merge branch 'arch_23135/add_an_option_to_start_the_agent_in_verbose_…
Browse files Browse the repository at this point in the history
…mode_pr' into branches/rudder/8.0
  • Loading branch information
amousset committed Jul 26, 2023
2 parents 63295ec + 0aee686 commit eca7447
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
8 changes: 7 additions & 1 deletion policies/rudderc/src/backends/unix/cfengine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ fn cfengine_canonify_condition(c: &str) -> String {
}
}

pub fn cf_agent(input: &Path, params: &Path, lib_path: &Path) -> Result<RunLog> {
pub fn cf_agent(
input: &Path,
params: &Path,
lib_path: &Path,
agent_verbose: bool,
) -> Result<RunLog> {
debug!("Running cf-agent on {}", input.display());
// Use a dedicated workdir for each test
// Required to run agents concurrently without trouble
Expand All @@ -164,6 +169,7 @@ pub fn cf_agent(input: &Path, params: &Path, lib_path: &Path) -> Result<RunLog>
};
let cmd = Command::new(Path::new(CF_BIN_DIR).join("cf-agent"))
.args([
if agent_verbose { "--verbose" } else { "--info" },
"--no-lock",
"--workdir",
&work_dir.path().to_string_lossy(),
Expand Down
4 changes: 4 additions & 0 deletions policies/rudderc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ pub enum Command {

/// Filter tests cases
filter: Option<String>,

/// Verbose agent
#[arg(long)]
agent_verbose: bool,
},

/// Build the method documentation
Expand Down
15 changes: 13 additions & 2 deletions policies/rudderc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@ pub fn run(args: MainArgs) -> Result<()> {
store_ids,
)
}
Command::Test { library, filter } => {
Command::Test {
library,
filter,
agent_verbose,
} => {
let library = check_libraries(library)?;
action::build(library.as_slice(), input, target.as_path(), true, false)?;
action::test(
target.join("technique.cf").as_path(),
Path::new(TESTS_DIR),
library.as_slice(),
filter,
agent_verbose,
)
}
Command::Lib {
Expand Down Expand Up @@ -285,6 +290,7 @@ pub mod action {
test_dir: &Path,
libraries: &[PathBuf],
filter: Option<String>,
agent_verbose: bool,
) -> Result<()> {
// Run everything relatively to the test directory
// Collect test cases
Expand Down Expand Up @@ -325,7 +331,12 @@ pub mod action {
if libraries.len() > 1 {
bail!("Tests only support one library path containing a full 'ncf' library");
}
let run_log = cf_agent(technique_file, case_path.as_path(), libraries[0].as_path())?;
let run_log = cf_agent(
technique_file,
case_path.as_path(),
libraries[0].as_path(),
agent_verbose,
)?;
let report_file = Path::new(TARGET_DIR).join(case_path.with_extension("json"));
create_dir_all(report_file.parent().unwrap())?;
fs::write(&report_file, serde_json::to_string_pretty(&run_log)?)?;
Expand Down
1 change: 1 addition & 0 deletions policies/rudderc/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fn test(filename: &str) {
technique_dir.join("tests").as_path(),
&[cwd.join(TEST_LIB)],
None,
false,
)
.unwrap();
}

0 comments on commit eca7447

Please sign in to comment.