* Add a test for importing derivations.
This commit is contained in:
		
							parent
							
								
									330df4b4db
								
							
						
					
					
						commit
						4c9fdd2cd6
					
				
					 3 changed files with 37 additions and 1 deletions
				
			
		| 
						 | 
					@ -9,7 +9,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
 | 
				
			||||||
  gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \
 | 
					  gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \
 | 
				
			||||||
  remote-store.sh export.sh export-graph.sh negative-caching.sh \
 | 
					  remote-store.sh export.sh export-graph.sh negative-caching.sh \
 | 
				
			||||||
  binary-patching.sh timeout.sh secure-drv-outputs.sh nix-channel.sh \
 | 
					  binary-patching.sh timeout.sh secure-drv-outputs.sh nix-channel.sh \
 | 
				
			||||||
  multiple-outputs.sh
 | 
					  multiple-outputs.sh import-derivation.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
XFAIL_TESTS =
 | 
					XFAIL_TESTS =
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,5 +37,6 @@ EXTRA_DIST = $(TESTS) \
 | 
				
			||||||
  timeout.nix timeout.builder.sh \
 | 
					  timeout.nix timeout.builder.sh \
 | 
				
			||||||
  secure-drv-outputs.nix \
 | 
					  secure-drv-outputs.nix \
 | 
				
			||||||
  multiple-outputs.nix \
 | 
					  multiple-outputs.nix \
 | 
				
			||||||
 | 
					  import-derivation.nix \
 | 
				
			||||||
  $(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \
 | 
					  $(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \
 | 
				
			||||||
  common.sh.in
 | 
					  common.sh.in
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										23
									
								
								tests/import-derivation.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								tests/import-derivation.nix
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					with import ./config.nix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bar = mkDerivation {
 | 
				
			||||||
 | 
					    name = "bar";
 | 
				
			||||||
 | 
					    builder = builtins.toFile "builder.sh"
 | 
				
			||||||
 | 
					      ''
 | 
				
			||||||
 | 
					        echo 'builtins.add 123 456' > $out
 | 
				
			||||||
 | 
					      '';
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  value = import bar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					in
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mkDerivation {
 | 
				
			||||||
 | 
					  name = "foo";
 | 
				
			||||||
 | 
					  builder = builtins.toFile "builder.sh"
 | 
				
			||||||
 | 
					    ''
 | 
				
			||||||
 | 
					      echo -n FOO${toString value} > $out
 | 
				
			||||||
 | 
					    '';
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										12
									
								
								tests/import-derivation.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								tests/import-derivation.sh
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					source common.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					clearStore
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if nix-instantiate --readonly-mode ./import-derivation.nix; then
 | 
				
			||||||
 | 
					    echo "read-only evaluation of an imported derivation unexpectedly failed"
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					outPath=$(nix-build ./import-derivation.nix)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[ "$(cat $outPath)" = FOO579 ]
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue