Skip to content

Commit 5f4bbbf

Browse files
barrbrainjhpratt
andauthored
Handle slashes in instance name of WaitExecutionRequest (#1689)
Co-authored-by: Jacob Pratt <[email protected]>
1 parent 840a5b3 commit 5f4bbbf

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

nativelink-service/BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ load(
33
"rust_doc",
44
"rust_doc_test",
55
"rust_library",
6+
"rust_test",
67
"rust_test_suite",
78
)
89

@@ -85,6 +86,25 @@ rust_test_suite(
8586
],
8687
)
8788

89+
rust_test(
90+
name = "unit_test",
91+
timeout = "short",
92+
crate = ":nativelink-service",
93+
proc_macro_deps = [
94+
"//nativelink-macro",
95+
"@crates//:async-trait",
96+
],
97+
deps = [
98+
"//nativelink-metric",
99+
"@crates//:async-lock",
100+
"@crates//:hyper",
101+
"@crates//:hyper-util",
102+
"@crates//:maplit",
103+
"@crates//:pretty_assertions",
104+
"@crates//:prost-types",
105+
],
106+
)
107+
88108
rust_doc(
89109
name = "docs",
90110
crate = ":nativelink-service",

nativelink-service/src/execution_server.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl NativelinkOperationId {
6262

6363
fn from_name(name: &str) -> Result<Self, Error> {
6464
let (instance_name, name) = name
65-
.split_once('/')
65+
.rsplit_once('/')
6666
.err_tip(|| "Expected instance_name and name to be separated by '/'")?;
6767
Ok(NativelinkOperationId::new(
6868
instance_name.to_string(),
@@ -383,3 +383,16 @@ impl Execution for ExecutionServer {
383383
resp
384384
}
385385
}
386+
387+
#[cfg(test)]
388+
#[test]
389+
fn test_nl_op_id_from_name() -> Result<(), Box<dyn std::error::Error>> {
390+
let examples = [("foo/bar", "foo"), ("a/b/c/d", "a/b/c")];
391+
392+
for (input, expected) in examples {
393+
let id = NativelinkOperationId::from_name(input)?;
394+
assert_eq!(id.instance_name, expected);
395+
}
396+
397+
Ok(())
398+
}

0 commit comments

Comments
 (0)