Skip to content

Commit

Permalink
adjust to upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Nov 29, 2024
1 parent f7dbc61 commit 4282b18
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 97 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
- run: cargo binstall cargo-codspeed
- uses: Swatinem/rust-cache@v2

- uses: actions/setup-python@v5

- run: cargo codspeed build
- uses: CodSpeedHQ/action@v3
with:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ on:
- main
pull_request:

env:
RUSTFLAGS: -Dwarnings

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions benches/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn create_random_testcases(
Testrun {
name,
classname: "".into(),
duration: 0.,
duration: Some(1.0),
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
Expand All @@ -197,7 +197,7 @@ fn randomize_test_data(rng: &mut impl Rng, uploads: &mut [Upload]) {

for upload in uploads {
for test in &mut upload.tests {
test.duration = durations.sample(rng);
test.duration = Some(durations.sample(rng));
test.outcome = match outcomes.sample(rng) {
0 => Outcome::Pass,
1 => Outcome::Skip,
Expand Down
114 changes: 24 additions & 90 deletions src/binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ mod tests {

use super::*;

fn test() -> Testrun {
Testrun {
name: "abc".into(),
classname: "".into(),
duration: Some(1.0),
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
filename: None,
build_url: None,
computed_name: None,
}
}

#[test]
fn test_empty() {
let writer = TestAnalyticsWriter::new(60);
Expand All @@ -30,30 +44,20 @@ mod tests {

#[test]
fn test_builder() {
let mut test = Testrun {
name: "abc".into(),
classname: "".into(),
duration: 1.0,
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
filename: None,
build_url: None,
computed_name: None,
};
let mut test = test();

let mut writer = TestAnalyticsWriter::new(2);
let mut session = writer.start_session(0, &[]);

session.insert(&test);

test.outcome = Outcome::Failure;
test.duration = 2.0;
test.duration = Some(2.0);
session.insert(&test);

test.name = "def".into();
test.outcome = Outcome::Skip;
test.duration = 0.0;
test.duration = Some(0.0);
session.insert(&test);

let mut buf = vec![];
Expand All @@ -79,17 +83,7 @@ mod tests {

#[test]
fn test_testsuites() {
let mut test = Testrun {
name: "abc".into(),
classname: "".into(),
duration: 1.0,
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
filename: None,
build_url: None,
computed_name: None,
};
let mut test = test();

let mut writer = TestAnalyticsWriter::new(2);
let mut session = writer.start_session(0, &[]);
Expand Down Expand Up @@ -117,17 +111,7 @@ mod tests {

#[test]
fn test_time_shift() {
let test = Testrun {
name: "abc".into(),
classname: "".into(),
duration: 1.0,
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
filename: None,
build_url: None,
computed_name: None,
};
let test = test();

let mut writer = TestAnalyticsWriter::new(2);
let mut session = writer.start_session(0, &[]);
Expand Down Expand Up @@ -171,17 +155,7 @@ mod tests {

#[test]
fn test_append_data() {
let test = Testrun {
name: "abc".into(),
classname: "".into(),
duration: 1.0,
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
filename: None,
build_url: None,
computed_name: None,
};
let test = test();

let mut writer = TestAnalyticsWriter::new(2);
let mut session = writer.start_session(0, &[]);
Expand Down Expand Up @@ -223,17 +197,7 @@ mod tests {

#[test]
fn test_merge() {
let test = Testrun {
name: "abc".into(),
classname: "".into(),
duration: 1.0,
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
filename: None,
build_url: None,
computed_name: None,
};
let test = test();

let mut writer = TestAnalyticsWriter::new(2);
let mut session = writer.start_session(0, &[]);
Expand Down Expand Up @@ -283,17 +247,7 @@ mod tests {

#[test]
fn test_garbage_collection() {
let test = Testrun {
name: "abc".into(),
classname: "".into(),
duration: 1.0,
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
filename: None,
build_url: None,
computed_name: None,
};
let test = test();

let mut writer = TestAnalyticsWriter::new(2);
let mut session = writer.start_session(0, &[]);
Expand Down Expand Up @@ -344,17 +298,7 @@ mod tests {

#[test]
fn test_flags() {
let test = Testrun {
name: "abc".into(),
classname: "".into(),
duration: 1.0,
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
filename: None,
build_url: None,
computed_name: None,
};
let test = test();

let mut writer = TestAnalyticsWriter::new(2);

Expand Down Expand Up @@ -394,17 +338,7 @@ mod tests {

#[test]
fn test_historic_data() {
let test = Testrun {
name: "abc".into(),
classname: "".into(),
duration: 1.0,
outcome: Outcome::Pass,
testsuite: "".into(),
failure_message: None,
filename: None,
build_url: None,
computed_name: None,
};
let test = test();

let mut writer = TestAnalyticsWriter::new(7);

Expand Down
4 changes: 2 additions & 2 deletions src/binary/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ impl InsertSession<'_> {
}

let testdata = &mut self.writer.testdata[data_idx];
testdata.total_duration += test.duration as f32;
testdata.total_duration += test.duration.unwrap_or_default() as f32;

if testdata.last_timestamp <= self.writer.timestamp {
testdata.last_timestamp = self.writer.timestamp;
testdata.last_duration = test.duration as f32;
testdata.last_duration = test.duration.unwrap_or_default() as f32;
}

match test.outcome {
Expand Down

0 comments on commit 4282b18

Please sign in to comment.