Skip to content

Commit

Permalink
Fix 1.75 build failure / add CI (#34)
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Co-authored-by: Michael X. Grey <[email protected]>
  • Loading branch information
luca-della-vedova and mxgrey authored Nov 27, 2024
1 parent 85501df commit d074da8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/ci_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ jobs:
run: cargo build --features single_threaded_async
- name: Test single_threaded_async
run: cargo test --features single_threaded_async

# Build and test with 1.75
- name: Install Rust 1.75
run: rustup default 1.75
- name: Build default features with Rust 1.75
run: cargo build
- name: Test default features with Rust 1.75
run: cargo test
52 changes: 51 additions & 1 deletion src/chain/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,12 @@ impl<T: 'static + Send + Sync, const N: usize> Splittable for [T; N] {

fn next(key: &Option<Self::Key>) -> Option<Self::Key> {
// Static arrays have a firm limit of N
SplitAsList::<Self>::next(key).take_if(|key| Self::validate(key))
let mut key = SplitAsList::<Self>::next(key);
if key.map_or(false, |key| Self::validate(&key)) {
key.take()
} else {
None
}
}

fn split(self, dispatcher: SplitDispatcher<'_, Self::Key, Self::Item>) -> OperationResult {
Expand Down Expand Up @@ -936,4 +941,49 @@ mod tests {
assert_eq!(result["fib"], input_map["fib"]);
assert_eq!(result["dib"], input_map["dib"]);
}

#[test]
fn test_array_split_limit() {
let mut context = TestingContext::minimal_plugins();

let workflow = context.spawn_io_workflow(|scope, builder| {
scope.input.chain(builder).split(|split| {
let err = split
.next_branch(|_, chain| {
chain.value().connect(scope.terminate);
})
.unwrap()
.next_branch(|_, chain| {
chain.value().connect(scope.terminate);
})
.unwrap()
.next_branch(|_, chain| {
chain.value().connect(scope.terminate);
})
.unwrap()
.next_branch(|_, chain| {
chain.value().connect(scope.terminate);
})
.unwrap()
// This last one should fail because it should exceed the
// array limit
.next_branch(|_, chain| {
chain.value().connect(scope.terminate);
});

assert!(matches!(err, Err(_)));
})
});

let mut promise =
context.command(|commands| commands.request([1, 2, 3, 4], workflow).take_response());

context.run_with_conditions(&mut promise, 1);
assert!(context.no_unhandled_errors());

let result = promise.take().available().unwrap();
// All the values in the array are racing to finish, but the first value
// should finish first since it will naturally get queued first.
assert_eq!(result, 1);
}
}

0 comments on commit d074da8

Please sign in to comment.