Skip to content

Commit 183c0b4

Browse files
Add test case for multiple ancestors not ready before try commit
1 parent d6104d5 commit 183c0b4

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

site/src/load.rs

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,120 @@ mod tests {
316316
use database::QueuedCommit;
317317

318318
use super::*;
319+
320+
// Checks that when we have a setup like the following, where a -> b means b
321+
// is the parent of a (i.e., must be tested before we can report comparison
322+
// results for a):
323+
//
324+
// a -> b
325+
// -> try-on-a
326+
//
327+
// the resulting ordering is:
328+
//
329+
// b
330+
// a
331+
// try-on-a
332+
//
333+
// which ensures that as each commit finishes, we have the results for it.
334+
//
335+
// Note that try-on-a does *not* have a direct dependency on b's results
336+
// being available; we could order b after ([a, try-on-a, b]) but this means
337+
// that we have to be more careful about posting comparison results, and to
338+
// most observers they expect those posted as soon as the PR's build in the
339+
// queue finishes: not doing so will look odd to onlookers.
340+
#[test]
341+
fn try_commit_ancestors() {
342+
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();
343+
let master_commits = vec![
344+
MasterCommit {
345+
sha: "a".into(),
346+
parent_sha: "b".into(),
347+
pr: Some(2),
348+
time,
349+
},
350+
MasterCommit {
351+
sha: "b".into(),
352+
parent_sha: "c".into(),
353+
pr: Some(1),
354+
time,
355+
},
356+
];
357+
let queued_pr_commits = vec![
358+
QueuedCommit {
359+
sha: "try-on-a".into(),
360+
parent_sha: "a".into(),
361+
pr: 3,
362+
include: None,
363+
exclude: None,
364+
runs: None,
365+
},
366+
QueuedCommit {
367+
sha: "b".into(),
368+
parent_sha: "c".into(),
369+
pr: 1,
370+
include: None,
371+
exclude: None,
372+
runs: None,
373+
},
374+
QueuedCommit {
375+
sha: "a".into(),
376+
parent_sha: "b".into(),
377+
pr: 2,
378+
include: None,
379+
exclude: None,
380+
runs: None,
381+
},
382+
];
383+
let in_progress_artifacts = vec![];
384+
// Have not benchmarked anything yet.
385+
let all_commits = HashSet::new();
386+
387+
let expected = vec![
388+
(
389+
Commit {
390+
sha: "b".into(),
391+
date: database::Date(time),
392+
},
393+
MissingReason::Master {
394+
pr: 1,
395+
parent_sha: "c".into(),
396+
is_try_parent: false,
397+
},
398+
),
399+
(
400+
Commit {
401+
sha: "a".into(),
402+
date: database::Date(time),
403+
},
404+
MissingReason::Master {
405+
pr: 2,
406+
parent_sha: "b".into(),
407+
is_try_parent: true,
408+
},
409+
),
410+
(
411+
Commit {
412+
sha: "try-on-a".into(),
413+
date: database::Date(time),
414+
},
415+
MissingReason::Try {
416+
pr: 3,
417+
include: None,
418+
exclude: None,
419+
runs: None,
420+
},
421+
),
422+
];
423+
let found = calculate_missing_from(
424+
master_commits,
425+
queued_pr_commits,
426+
in_progress_artifacts,
427+
all_commits,
428+
time,
429+
);
430+
assert_eq!(expected, found, "{:#?} != {:#?}", expected, found);
431+
}
432+
319433
#[test]
320434
fn calculates_missing_correct() {
321435
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();

0 commit comments

Comments
 (0)