summaryrefslogtreecommitdiffstats
path: root/src/pipeline/dispatch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pipeline/dispatch.rs')
-rw-r--r--src/pipeline/dispatch.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/pipeline/dispatch.rs b/src/pipeline/dispatch.rs
index 89a8788..aea934e 100644
--- a/src/pipeline/dispatch.rs
+++ b/src/pipeline/dispatch.rs
@@ -68,7 +68,21 @@ fn dispatcher(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>, tx: Sender<String
}
}
+/// The scheduler loop calls it; a test drives single ticks and needs it directly.
+///
+/// Module-internal in a production build, `pub` only under `test-support`:
+/// one body behind two visibility declarations, exactly one of which compiles.
+#[cfg(feature = "test-support")]
pub fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String> {
+ dispatch_once_impl(cfg, db, tx)
+}
+
+#[cfg(not(feature = "test-support"))]
+pub(crate) fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String> {
+ dispatch_once_impl(cfg, db, tx)
+}
+
+fn dispatch_once_impl(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String> {
let reaped = builds::reap_expired(db).unwrap_or(0);
if reaped > 0 {
db::audit_system(
@@ -97,7 +111,21 @@ pub fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String>
ids
}
+/// Production reaches this through `dispatch_once`, which is the only thing that acts on the answer.
+///
+/// Module-internal in a production build, `pub` only under `test-support`:
+/// one body behind two visibility declarations, exactly one of which compiles.
+#[cfg(feature = "test-support")]
pub fn admissible(cfg: &Config, db: &Db) -> usize {
+ admissible_impl(cfg, db)
+}
+
+#[cfg(not(feature = "test-support"))]
+pub(crate) fn admissible(cfg: &Config, db: &Db) -> usize {
+ admissible_impl(cfg, db)
+}
+
+fn admissible_impl(cfg: &Config, db: &Db) -> usize {
let in_flight = builds::in_flight(db).unwrap_or(0) as usize;
let slots = cfg.max_concurrent_builds.saturating_sub(in_flight);
if slots == 0 {
@@ -110,7 +138,21 @@ pub fn admissible(cfg: &Config, db: &Db) -> usize {
slots
}
+/// Production reaches this through `admissible`, which is the only thing that acts on the number.
+///
+/// Module-internal in a production build, `pub` only under `test-support`:
+/// one body behind two visibility declarations, exactly one of which compiles.
+#[cfg(feature = "test-support")]
pub fn free_disk_mb(path: &std::path::Path) -> u64 {
+ free_disk_mb_impl(path)
+}
+
+#[cfg(not(feature = "test-support"))]
+pub(crate) fn free_disk_mb(path: &std::path::Path) -> u64 {
+ free_disk_mb_impl(path)
+}
+
+fn free_disk_mb_impl(path: &std::path::Path) -> u64 {
use std::ffi::CString;
let c = match CString::new(path.as_os_str().to_string_lossy().as_bytes()) {
Ok(c) => c,