Skip to content

Commit

Permalink
Adjust the sync-multi test to just care about relative order of event…
Browse files Browse the repository at this point in the history
…s, the actual time taken doesn't matter
  • Loading branch information
TrentHouliston committed Dec 23, 2024
1 parent 7ca97d8 commit 4fefe3c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tests/tests/dsl/SyncMulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ class TestReactor : public test_util::TestBase<TestReactor> {
struct B {};

void do_task(const std::string& event) {
auto start = test_util::round_to_test_units(std::chrono::steady_clock::now() - start_time);
events.push_back(event + " started @ " + std::to_string(start.count()));
events.emplace_back(event + " started");
// Sleep for a bit to give a chance for the other threads to cause problems
NUClear::util::precise_sleep(test_util::TimeUnit(2));
auto end = test_util::round_to_test_units(std::chrono::steady_clock::now() - start_time);
events.push_back(event + " finished @ " + std::to_string(end.count()));
events.emplace_back(event + " finished");
}

TestReactor(std::unique_ptr<NUClear::Environment> environment) : TestBase(std::move(environment)) {
Expand Down Expand Up @@ -72,12 +70,12 @@ TEST_CASE("Test that sync works when one thread has multiple groups", "[api][syn
plant.start();

const std::vector<std::string> expected = {
"Sync A started @ 0",
"Sync A finished @ 2",
"Sync Both started @ 2",
"Sync Both finished @ 4",
"Sync B started @ 4",
"Sync B finished @ 6",
"Sync A started",
"Sync A finished",
"Sync Both started",
"Sync Both finished",
"Sync B started",
"Sync B finished",
};

// Make an info print the diff in an easy to read way if we fail
Expand Down

0 comments on commit 4fefe3c

Please sign in to comment.