From f86957828479b4f5e1fcf969067c6cbf2051e33a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Mon, 3 Jul 2023 13:02:24 +0000 Subject: [PATCH] add tests for `extract_perf_shas` Some real-world examples in the 2 different formats --- src/main.rs | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/main.rs b/src/main.rs index 8d2bb61..cdf61b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1354,4 +1354,74 @@ mod tests { validate_dir(main).unwrap_err() ) } + + // Ensure the first version of the comment posted by the perf-bot works + #[test] + fn test_perf_builds_v1_format() { + // Body extracted from this v1 comment + // https://github.com/rust-lang/rust/pull/113014#issuecomment-1605868471 + let body = "📌 Perf builds for each rolled up PR: + +|PR# | Perf Build Sha| +|----|:-----:| +|#113009|[05b07dad146a6d43ead9bcd1e8bc10cbd017a5f5](https://github.com/rust-lang-ci/rust/commit/05b07dad146a6d43ead9bcd1e8bc10cbd017a5f5)| +|#113008|[581913b6789370def5158093b799baa6d4d875eb](https://github.com/rust-lang-ci/rust/commit/581913b6789370def5158093b799baa6d4d875eb)| +|#112956|[e294bd3827eb2e878167329648f3c8178ef344e7](https://github.com/rust-lang-ci/rust/commit/e294bd3827eb2e878167329648f3c8178ef344e7)| +|#112950|[0ed6ba504649ca1cb2672572b4ab41acfb06c86c](https://github.com/rust-lang-ci/rust/commit/0ed6ba504649ca1cb2672572b4ab41acfb06c86c)| +|#112937|[18e108ab85b78e6966c5b5bdadfd5b8efeadf080](https://github.com/rust-lang-ci/rust/commit/18e108ab85b78e6966c5b5bdadfd5b8efeadf080)| + + +*previous master*: [f7ca9df695](https://github.com/rust-lang-ci/rust/commit/f7ca9df69549470541fbf542f87a03eb9ed024b6) + +In the case of a perf regression, run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA` +"; + assert_eq!( + vec![ + "05b07dad146a6d43ead9bcd1e8bc10cbd017a5f5", + "581913b6789370def5158093b799baa6d4d875eb", + "e294bd3827eb2e878167329648f3c8178ef344e7", + "0ed6ba504649ca1cb2672572b4ab41acfb06c86c", + "18e108ab85b78e6966c5b5bdadfd5b8efeadf080", + ], + extract_perf_shas(body).expect("extracting perf builds on v1 format failed"), + ); + } + + // Ensure the second version of the comment posted by the perf-bot works + #[test] + fn test_perf_builds_v2_format() { + // Body extracted from this v2 comment + // https://github.com/rust-lang/rust/pull/113105#issuecomment-1610393473 + let body = "📌 Perf builds for each rolled up PR: + +| PR# | Message | Perf Build Sha | +|----|----|:-----:| +|#112207|Add trustzone and virtualization target features for aarch3…|`bbec6d6e413aa144c8b9346da27a0f2af299cbeb` ([link](https://github.com/rust-lang-ci/rust/commit/bbec6d6e413aa144c8b9346da27a0f2af299cbeb))| +|#112454|Make compiletest aware of targets without dynamic linking|`70b67c09ead52f4582471650202b1a189821ed5f` ([link](https://github.com/rust-lang-ci/rust/commit/70b67c09ead52f4582471650202b1a189821ed5f))| +|#112628|Allow comparing `Box`es with different allocators|`3043f4e577f41565443f38a6a16b7a1a08b063ad` ([link](https://github.com/rust-lang-ci/rust/commit/3043f4e577f41565443f38a6a16b7a1a08b063ad))| +|#112692|Provide more context for `rustc +nightly -Zunstable-options…|`4ab6f33fd50237b105999cc6d32d85cce5dad61a` ([link](https://github.com/rust-lang-ci/rust/commit/4ab6f33fd50237b105999cc6d32d85cce5dad61a))| +|#112972|Make `UnwindAction::Continue` explicit in MIR dump|`e1df9e306054655d7d41ec1ad75ade5d76a6888d` ([link](https://github.com/rust-lang-ci/rust/commit/e1df9e306054655d7d41ec1ad75ade5d76a6888d))| +|#113020|Add tests impl via obj unless denied|`affe009b94eba41777cf02997b1780e50445d6af` ([link](https://github.com/rust-lang-ci/rust/commit/affe009b94eba41777cf02997b1780e50445d6af))| +|#113084|Simplify some conditions|`0ce4618dbf5810aabb389edd4950c060b6b4d049` ([link](https://github.com/rust-lang-ci/rust/commit/0ce4618dbf5810aabb389edd4950c060b6b4d049))| +|#113103|Normalize types when applying uninhabited predicate.|`241cd8cd818cdc865cdf02f0c32a40081420b772` ([link](https://github.com/rust-lang-ci/rust/commit/241cd8cd818cdc865cdf02f0c32a40081420b772))| + + +*previous master*: [5ea6668646](https://github.com/rust-lang-ci/rust/commit/5ea66686467d3ec5f8c81570e7f0f16ad8dd8cc3) + +In the case of a perf regression, run the following command for each PR you suspect might be the cause: `@rust-timer build $SHA` +"; + assert_eq!( + vec![ + "bbec6d6e413aa144c8b9346da27a0f2af299cbeb", + "70b67c09ead52f4582471650202b1a189821ed5f", + "3043f4e577f41565443f38a6a16b7a1a08b063ad", + "4ab6f33fd50237b105999cc6d32d85cce5dad61a", + "e1df9e306054655d7d41ec1ad75ade5d76a6888d", + "affe009b94eba41777cf02997b1780e50445d6af", + "0ce4618dbf5810aabb389edd4950c060b6b4d049", + "241cd8cd818cdc865cdf02f0c32a40081420b772", + ], + extract_perf_shas(body).expect("extracting perf builds on v2 format failed"), + ); + } }