Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrolich committed Apr 3, 2024
1 parent 3976da6 commit 60f7705
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
17 changes: 12 additions & 5 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,14 @@ pub fn initialize_build<'a>(
total_cleanup,
default_timing.unwrap_or(timing_cleanup_elapsed).as_secs_f64()
);
// repair broken state
mark_modules_with_expired_deps_dirty(&mut build_state);
mark_modules_with_deleted_deps_dirty(&mut build_state);
Ok(build_state)
}

pub fn incremental_build(build_state: &mut BuildState, default_timing: Option<Duration>) -> Result<(), ()> {
pub fn incremental_build(
build_state: &mut BuildState,
default_timing: Option<Duration>,
initial_build: bool,
) -> Result<(), ()> {
logs::initialize(&build_state.packages);
let num_dirty_modules = build_state.modules.values().filter(|m| is_dirty(m)).count() as u64;

Expand Down Expand Up @@ -265,6 +266,12 @@ pub fn incremental_build(build_state: &mut BuildState, default_timing: Option<Du
default_timing.unwrap_or(timing_deps_elapsed).as_secs_f64()
);

if initial_build {
// repair broken state
mark_modules_with_expired_deps_dirty(build_state);
}
mark_modules_with_deleted_deps_dirty(build_state);

// print all the compile_dirty modules
// for (module_name, module) in build_state.modules.iter() {
// if module.compile_dirty {
Expand Down Expand Up @@ -326,7 +333,7 @@ pub fn build(filter: &Option<regex::Regex>, path: &str, no_timing: bool) -> Resu
};
let timing_total = Instant::now();
let mut build_state = initialize_build(default_timing, filter, path)?;
match incremental_build(&mut build_state, default_timing) {
match incremental_build(&mut build_state, default_timing, true) {
Ok(_) => {
let timing_total_elapsed = timing_total.elapsed();
println!(
Expand Down
7 changes: 5 additions & 2 deletions src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ async fn async_watch(
// create a mutex to capture if ctrl-c was pressed
let ctrlc_pressed = Arc::new(Mutex::new(false));
let ctrlc_pressed_clone = Arc::clone(&ctrlc_pressed);
let mut initial_build = true;

ctrlc::set_handler(move || {
let pressed = Arc::clone(&ctrlc_pressed);
Expand Down Expand Up @@ -158,7 +159,7 @@ async fn async_watch(
match needs_compile_type {
CompileType::Incremental => {
let timing_total = Instant::now();
let _ = build::incremental_build(&mut build_state, None);
let _ = build::incremental_build(&mut build_state, None, initial_build);
after_build.clone().map(|command| cmd::run(command));
let timing_total_elapsed = timing_total.elapsed();
println!(
Expand All @@ -168,11 +169,12 @@ async fn async_watch(
timing_total_elapsed.as_secs_f64()
);
needs_compile_type = CompileType::None;
initial_build = false;
}
CompileType::Full => {
let timing_total = Instant::now();
build_state = build::initialize_build(None, filter, path).expect("Can't initialize build");
let _ = build::incremental_build(&mut build_state, None);
let _ = build::incremental_build(&mut build_state, None, initial_build);
after_build.clone().map(|command| cmd::run(command));
let timing_total_elapsed = timing_total.elapsed();
println!(
Expand All @@ -182,6 +184,7 @@ async fn async_watch(
timing_total_elapsed.as_secs_f64()
);
needs_compile_type = CompileType::None;
initial_build = false;
}
CompileType::None => {
// We want to sleep for a little while so the CPU can schedule other work. That way we end
Expand Down

0 comments on commit 60f7705

Please sign in to comment.