Skip to content

Commit

Permalink
debug ci
Browse files Browse the repository at this point in the history
  • Loading branch information
pnordahl committed Nov 14, 2024
1 parent 8858f1e commit 4b8c98f
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 76 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ jobs:
monorail:
name: monorail
runs-on: ubuntu-latest
env:
MONORAIL_TEST_DIR : ${{ github.workspace }}/tmp
steps:
- name: Create tmp directory
run: mkdir -p $MONORAIL_TEST_DIR
steps:
- name: prep
run: |
Expand Down
15 changes: 7 additions & 8 deletions src/app/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,11 @@ pub(crate) fn analyze(
mod tests {
use super::*;
use crate::core::testing::*;
use tempfile::tempdir;

#[tokio::test]
async fn test_analyze_empty() {
let changes = vec![];
let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let mut index = core::Index::new(&c, &c.get_target_path_set(), work_path).unwrap();
Expand All @@ -412,7 +411,7 @@ mod tests {
targets: Some(vec![]),
}];

let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let mut index = core::Index::new(&c, &c.get_target_path_set(), work_path).unwrap();
Expand Down Expand Up @@ -441,7 +440,7 @@ mod tests {
}]),
}];

let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let mut index = core::Index::new(&c, &c.get_target_path_set(), work_path).unwrap();
Expand Down Expand Up @@ -469,7 +468,7 @@ mod tests {
}]),
}];

let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let mut index = core::Index::new(&c, &c.get_target_path_set(), work_path).unwrap();
Expand Down Expand Up @@ -509,7 +508,7 @@ mod tests {
]),
}];

let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let mut index = core::Index::new(&c, &c.get_target_path_set(), work_path).unwrap();
Expand Down Expand Up @@ -545,7 +544,7 @@ mod tests {
]),
}];

let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let mut index = core::Index::new(&c, &c.get_target_path_set(), work_path).unwrap();
Expand Down Expand Up @@ -595,7 +594,7 @@ mod tests {
},
];

let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let mut index = core::Index::new(&c, &c.get_target_path_set(), work_path).unwrap();
Expand Down
9 changes: 4 additions & 5 deletions src/app/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ mod tests {
use super::*;
use crate::core::git;
use crate::core::testing::*;
use tempfile::tempdir;

#[tokio::test]
async fn test_handle_checkpoint_delete_success() {
let td2 = tempdir().unwrap();
let td2 = new_testdir().unwrap();
let rp = &td2.path();
let cfg = new_test_repo(rp).await;
let tracking_path = cfg.get_tracking_path(rp);
Expand All @@ -131,7 +130,7 @@ mod tests {

#[tokio::test]
async fn test_handle_checkpoint_show_success() {
let td2 = tempdir().unwrap();
let td2 = new_testdir().unwrap();
let rp = &td2.path();
let cfg = new_test_repo(rp).await;
let tracking_path = cfg.get_tracking_path(rp);
Expand All @@ -151,7 +150,7 @@ mod tests {

#[tokio::test]
async fn test_handle_checkpoint_update_with_pending_changes() {
let td2 = tempdir().unwrap();
let td2 = new_testdir().unwrap();
let rp = &td2.path();
let cfg = new_test_repo(rp).await;
let head = get_head(rp).await;
Expand All @@ -172,7 +171,7 @@ mod tests {

#[tokio::test]
async fn test_handle_checkpoint_update_no_pending_changes() {
let td2 = tempdir().unwrap();
let td2 = new_testdir().unwrap();
let rp = &td2.path();
let cfg = new_test_repo(rp).await;
let git_opts: git::GitOptions = Default::default();
Expand Down
8 changes: 4 additions & 4 deletions src/app/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,11 @@ pub(crate) fn get_header(filename: &str, target: &str, command: &str, color: boo
#[cfg(test)]
mod tests {
use super::*;
use crate::core::testing::*;
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use tempfile::tempdir;

#[test]
fn test_compressor_initialization() {
Expand All @@ -521,7 +521,7 @@ mod tests {
fn test_register_paths() {
let shutdown = Arc::new(AtomicBool::new(false));
let mut compressor = Compressor::new(2, shutdown.clone());
let temp_dir = tempdir().unwrap();
let temp_dir = new_testdir().unwrap();

// Register a path and validate the returned CompressorClient
let test_path = temp_dir.path().join("test_file_1");
Expand Down Expand Up @@ -549,7 +549,7 @@ mod tests {
fn test_run_compressor_with_data_requests() {
let shutdown = Arc::new(AtomicBool::new(false));
let mut compressor = Compressor::new(1, shutdown.clone());
let temp_dir = tempdir().unwrap();
let temp_dir = new_testdir().unwrap();

let test_path = temp_dir.path().join("test_output.zst");
let client = compressor
Expand Down Expand Up @@ -584,7 +584,7 @@ mod tests {
fn test_shutdown_compressor() {
let shutdown = Arc::new(AtomicBool::new(false));
let mut compressor = Compressor::new(2, shutdown.clone());
let temp_dir = tempdir().unwrap();
let temp_dir = new_testdir().unwrap();

// Register paths
let test_path_1 = temp_dir.path().join("test_file_1");
Expand Down
79 changes: 38 additions & 41 deletions src/app/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,45 +1107,42 @@ mod tests {

// test_handle_run_cmd_error (failed == true)

// #[tokio::test]
// async fn test_handle_run_cmd_error() {
// let td = tempdir().unwrap();
// let work_path = &td.path();
// let c = new_test_repo(work_path).await;
// let command = "cmd1".to_string();
// let t1 = "target1".to_string();
// let t2 = "target2".to_string();
// let input = setup_handle_run_input(
// vec![&command],
// HashSet::from([&t1, &t2]),
// vec![],
// vec![],
// vec![],
// );

// let o = handle_run(&c, &input, "x", work_path).await.unwrap();
// assert!(o.failed);

// let crr = &o.results[0];
// assert_eq!(crr.command, "cmd1");
// for tg in &crr.target_groups {
// for (target, trr) in tg {
// if *target == t1 {
// assert_eq!(trr.status, RunStatus::Error);
// assert_eq!(trr.code, Some(1));
// assert!(trr.runtime_secs.is_some());
// } else if *target == t2 {
// assert_eq!(trr.status, RunStatus::Skipped);
// assert_eq!(trr.code, None);
// assert!(trr.runtime_secs.is_none());
// }
// }
// }
// }
#[tokio::test]
async fn test_handle_run_cmd_error() {
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let command = "cmd1".to_string();
let t1 = "target1".to_string();
let t2 = "target2".to_string();
let input = setup_handle_run_input(
vec![&command],
HashSet::from([&t1, &t2]),
vec![],
vec![],
vec![],
);

let o = handle_run(&c, &input, "x", work_path).await.unwrap();
assert!(o.failed);

let crr = &o.results[0];
assert_eq!(crr.command, "cmd1");

for tg in &crr.target_groups {
for (target, trr) in tg {
if *target == t1 {
assert_eq!(trr.status, RunStatus::Error);
assert_eq!(trr.code, Some(1));
assert!(trr.runtime_secs.is_some());
}
}
}
}

#[tokio::test]
async fn test_handle_run() {
let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let command = "cmd0".to_string();
Expand Down Expand Up @@ -1196,7 +1193,7 @@ mod tests {

#[test]
fn test_argmap_single_command_target_all() {
let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let command = "build".to_string();
let target = "rust/crate1".to_string();
let arg1 = "--plorp".to_string();
Expand Down Expand Up @@ -1326,7 +1323,7 @@ mod tests {

#[test]
fn test_argmap_valid_file() {
let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let command = "build".to_string();
let target = "rust/crate1".to_string();

Expand Down Expand Up @@ -1358,7 +1355,7 @@ mod tests {

#[test]
fn test_argmap_invalid_file() {
let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let path = td.path().join("invalid_argmap.json");
std::fs::write(&path, r#"{lksjdfklj"#).expect("Failed to write test file");
let path_str = path.display().to_string();
Expand Down Expand Up @@ -1410,7 +1407,7 @@ mod tests {

#[tokio::test]
async fn test_process_plan() {
let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let cfg = new_test_repo(work_path).await;
let cmd1 = "cmd2".to_string();
Expand Down Expand Up @@ -1450,7 +1447,7 @@ mod tests {

#[tokio::test]
async fn test_get_plan() {
let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let work_path = &td.path();
let c = new_test_repo(work_path).await;
let index = core::Index::new(&c, &c.get_target_path_set(), work_path).unwrap();
Expand Down
16 changes: 8 additions & 8 deletions src/core/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ mod tests {

#[test]
fn test_contains_file_with_file() {
let temp_dir = tempdir().unwrap();
let temp_dir = new_testdir().unwrap();
let file_path = temp_dir.path().join("test_file.txt");
fs::write(&file_path, "Hello, world!").unwrap();

Expand All @@ -134,7 +134,7 @@ mod tests {

#[test]
fn test_contains_file_with_directory_containing_file() {
let temp_dir = tempdir().unwrap();
let temp_dir = new_testdir().unwrap();
let file_path = temp_dir.path().join("test_file.txt");
fs::write(file_path, "Hello, world!").unwrap();

Expand All @@ -144,13 +144,13 @@ mod tests {

#[test]
fn test_contains_file_with_empty_directory() {
let temp_dir = tempdir().unwrap();
let temp_dir = new_testdir().unwrap();
assert!(contains_file(temp_dir.path()).is_err());
}

#[test]
fn test_contains_file_with_nested_directory_with_file() {
let temp_dir = tempdir().unwrap();
let temp_dir = new_testdir().unwrap();
let nested_dir = temp_dir.path().join("nested");
fs::create_dir(&nested_dir).unwrap();
let nested_file_path = nested_dir.join("nested_file.txt");
Expand All @@ -162,7 +162,7 @@ mod tests {

#[test]
fn test_contains_file_with_nested_empty_directories() {
let temp_dir = tempdir().unwrap();
let temp_dir = new_testdir().unwrap();
let nested_dir = temp_dir.path().join("nested");
fs::create_dir(nested_dir).unwrap();

Expand All @@ -172,7 +172,7 @@ mod tests {

#[test]
fn test_contains_file_with_multiple_directories_one_with_file() {
let temp_dir = tempdir().unwrap();
let temp_dir = new_testdir().unwrap();
let dir1 = temp_dir.path().join("dir1");
let dir2 = temp_dir.path().join("dir2");
fs::create_dir(dir1).unwrap();
Expand All @@ -186,7 +186,7 @@ mod tests {

#[tokio::test]
async fn test_checksum_is_equal() {
let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let repo_path = &td.path();
init(repo_path, false).await;
let fname1 = "test1.txt";
Expand Down Expand Up @@ -216,7 +216,7 @@ mod tests {

#[tokio::test]
async fn test_get_file_checksum() {
let td = tempdir().unwrap();
let td = new_testdir().unwrap();
let repo_path = &td.path();
init(repo_path, false).await;

Expand Down
Loading

0 comments on commit 4b8c98f

Please sign in to comment.