Skip to content

Commit 551de41

Browse files
committed
pipeline-manager: flatten for-loop in Rust compiler source checksum test
Signed-off-by: Simon Kassing <[email protected]>
1 parent 53b20eb commit 551de41

File tree

3 files changed

+55
-32
lines changed

3 files changed

+55
-32
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pipeline-manager/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ aws-sdk-cognitoidentityprovider = "0.28.0"
8686
aws-config = "0.55.3"
8787
wiremock = "0.6"
8888
feldera-types = { path = "../feldera-types", features = ["testing"] }
89+
itertools = "0.13.0"
8990

9091
# Used in integration tests
9192
[dev-dependencies.tokio]

crates/pipeline-manager/src/compiler/rust_compiler.rs

+53-32
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,8 @@ mod test {
10921092

10931093
/// Tests the calculation of the source checksum.
10941094
#[tokio::test]
1095-
#[rustfmt::skip]
10961095
async fn source_checksum_calculation() {
1096+
// Calling with different input yields a different checksum
10971097
let config_1 = CompilerConfig {
10981098
compiler_working_directory: "".to_string(),
10991099
compilation_profile: CompilationProfile::Dev,
@@ -1135,33 +1135,54 @@ mod test {
11351135
cache: false,
11361136
};
11371137
let mut seen = HashSet::<String>::new();
1138-
for platform_version in ["", "v1", "v2"] {
1139-
for profile in [CompilationProfile::Dev, CompilationProfile::Optimized, CompilationProfile::Unoptimized] {
1140-
for config in [config_1.clone(), config_2.clone(), config_3.clone(), config_4.clone()] {
1141-
for program_config in [program_config_1.clone()] {
1142-
for main_rust in ["", "a", "aa", "b", "c", "d", "e"] {
1143-
for udf_stubs in ["", "a", "aa", "b", "c", "d", "e"] {
1144-
for udf_rust in ["", "a", "aa", "b", "c", "d", "e"] {
1145-
for udf_toml in ["", "a", "aa", "b", "c", "d", "e"] {
1146-
let source_checksum = calculate_source_checksum(
1147-
platform_version,
1148-
&profile,
1149-
&config,
1150-
&program_config,
1151-
main_rust,
1152-
udf_stubs,
1153-
udf_rust,
1154-
udf_toml
1155-
);
1156-
assert!(!seen.contains(&source_checksum), "checksum {source_checksum} has a duplicate");
1157-
seen.insert(source_checksum);
1158-
}
1159-
}
1160-
}
1161-
}
1162-
}
1163-
}
1164-
}
1138+
let platform_versions = ["", "v1", "v2"];
1139+
let profiles = [
1140+
CompilationProfile::Dev,
1141+
CompilationProfile::Optimized,
1142+
CompilationProfile::Unoptimized,
1143+
];
1144+
let configs = [
1145+
config_1.clone(),
1146+
config_2.clone(),
1147+
config_3.clone(),
1148+
config_4.clone(),
1149+
];
1150+
let program_configs = [program_config_1.clone()];
1151+
let content = ["", "a", "aa", "b", "c", "d", "e"];
1152+
for (
1153+
platform_version,
1154+
profile,
1155+
config,
1156+
program_config,
1157+
main_rust,
1158+
udf_stubs,
1159+
udf_rust,
1160+
udf_toml,
1161+
) in itertools::iproduct!(
1162+
platform_versions,
1163+
profiles,
1164+
configs,
1165+
program_configs,
1166+
content,
1167+
content,
1168+
content,
1169+
content
1170+
) {
1171+
let source_checksum = calculate_source_checksum(
1172+
platform_version,
1173+
&profile,
1174+
&config,
1175+
&program_config,
1176+
main_rust,
1177+
udf_stubs,
1178+
udf_rust,
1179+
udf_toml,
1180+
);
1181+
assert!(
1182+
!seen.contains(&source_checksum),
1183+
"checksum {source_checksum} has a duplicate"
1184+
);
1185+
seen.insert(source_checksum);
11651186
}
11661187

11671188
// Calling with the same input yields the same checksum
@@ -1173,7 +1194,7 @@ mod test {
11731194
"main_rust",
11741195
"udf_stubs",
11751196
"udf_rust",
1176-
"udf_toml"
1197+
"udf_toml",
11771198
);
11781199
let checksum2 = calculate_source_checksum(
11791200
"v0",
@@ -1183,7 +1204,7 @@ mod test {
11831204
"main_rust",
11841205
"udf_stubs",
11851206
"udf_rust",
1186-
"udf_toml"
1207+
"udf_toml",
11871208
);
11881209
assert_eq!(checksum1, checksum2);
11891210

@@ -1199,7 +1220,7 @@ mod test {
11991220
"main_rust",
12001221
"udf_stubs",
12011222
"udf_rust",
1202-
"udf_toml"
1223+
"udf_toml",
12031224
);
12041225
let checksum2 = calculate_source_checksum(
12051226
"v0",
@@ -1212,7 +1233,7 @@ mod test {
12121233
"main_rust",
12131234
"udf_stubs",
12141235
"udf_rust",
1215-
"udf_toml"
1236+
"udf_toml",
12161237
);
12171238
assert_eq!(checksum1, checksum2);
12181239
}

0 commit comments

Comments
 (0)