feat(tvix/nix-compat): have StorePath accept bytes
The primary constructor for this is now from_bytes, from_string is simply calling .as_bytes() on the string, passing it along. The InvalidName error now contains a Vec<u8>, to encode the invalid name (which might not be a string anymore). from_absolute_path now accepts a &[u8] (even though we might want to make this a OSString of some sort). StorePath::validate_name has been degraded to a pub(crate) function. It's still used in src/derivation, even though it probably shouldn't at all - that cleanup is left for cl/8412 though. Change-Id: I6b4e62a6fa5c4bec13b535279e73444f0b83ad35 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8973 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
parent
5364fcb127
commit
42dc18353d
8 changed files with 84 additions and 68 deletions
|
|
@ -6,6 +6,7 @@ use std::collections::BTreeSet;
|
|||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use test_case::test_case;
|
||||
use test_generator::test_resources;
|
||||
|
||||
|
|
@ -67,7 +68,7 @@ fn derivation_path(name: &str, expected_path: &str) {
|
|||
|
||||
assert_eq!(
|
||||
derivation.calculate_derivation_path(name).unwrap(),
|
||||
StorePath::from_string(expected_path).unwrap()
|
||||
StorePath::from_str(expected_path).unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +308,7 @@ fn output_path_construction() {
|
|||
assert_eq!(foo_drv_expected, foo_drv);
|
||||
|
||||
assert_eq!(
|
||||
StorePath::from_string("4wvvbi4jwn0prsdxb7vs673qa5h9gr7x-foo.drv").expect("must succeed"),
|
||||
StorePath::from_str("4wvvbi4jwn0prsdxb7vs673qa5h9gr7x-foo.drv").expect("must succeed"),
|
||||
foo_drv
|
||||
.calculate_derivation_path("foo")
|
||||
.expect("must succeed")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue