feat(tvix/tests): Import default.nix inside directory
This requires actually passing the source directory into `interpret` in the eval tests, but otherwise this is fairly straightforward - if we're trying to import a directory, just push `default.nix` onto it and import that instead. Change-Id: I0b7d4234f81977e78d14dfa651bf0cf9721017e5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6893 Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									278bccc1ea
								
							
						
					
					
						commit
						b4d978cd6a
					
				
					 5 changed files with 11 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -52,7 +52,10 @@ pub fn builtins_import(
 | 
			
		|||
        "import",
 | 
			
		||||
        &[true],
 | 
			
		||||
        move |mut args: Vec<Value>, vm: &mut VM| {
 | 
			
		||||
            let path = super::coerce_value_to_path(&args.pop().unwrap(), vm)?;
 | 
			
		||||
            let mut path = super::coerce_value_to_path(&args.pop().unwrap(), vm)?;
 | 
			
		||||
            if path.is_dir() {
 | 
			
		||||
                path.push("default.nix");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            let contents =
 | 
			
		||||
                std::fs::read_to_string(&path).map_err(|err| ErrorKind::ReadFileError {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue