* Test whether sequences of patches work.
This commit is contained in:
		
							parent
							
								
									1a211d812f
								
							
						
					
					
						commit
						d92ccbf1ac
					
				
					 2 changed files with 37 additions and 15 deletions
				
			
		| 
						 | 
					@ -8,8 +8,11 @@ mkDerivation {
 | 
				
			||||||
    ''
 | 
					    ''
 | 
				
			||||||
      mkdir $out
 | 
					      mkdir $out
 | 
				
			||||||
      seq 1 1000000 > $out/foo
 | 
					      seq 1 1000000 > $out/foo
 | 
				
			||||||
      ${if version == 2 then ''
 | 
					      ${if version != 1 then ''
 | 
				
			||||||
        seq 1000000 1010000 >> $out/foo
 | 
					        seq 1000000 1010000 >> $out/foo
 | 
				
			||||||
      '' else ""}
 | 
					      '' else ""}
 | 
				
			||||||
 | 
					      ${if version == 3 then ''
 | 
				
			||||||
 | 
					        echo foobar >> $out/foo
 | 
				
			||||||
 | 
					      '' else ""}
 | 
				
			||||||
    '';
 | 
					    '';
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,28 +12,47 @@ $NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest1 \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
out2=$($nixbuild -o $RESULT binary-patching.nix --arg version 2)
 | 
					out2=$($nixbuild -o $RESULT binary-patching.nix --arg version 2)
 | 
				
			||||||
$NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest2 $out2
 | 
					$NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest2 $out2
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					out3=$($nixbuild -o $RESULT binary-patching.nix --arg version 3)
 | 
				
			||||||
 | 
					$NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest3 $out3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
rm $RESULT
 | 
					rm $RESULT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Generate a binary patch.
 | 
					# Generate binary patches.
 | 
				
			||||||
$NIX_BIN_DIR/generate-patches.pl $TEST_ROOT/cache2 $TEST_ROOT/patches \
 | 
					$NIX_BIN_DIR/generate-patches.pl $TEST_ROOT/cache2 $TEST_ROOT/patches \
 | 
				
			||||||
    file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest2
 | 
					    file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
grep -q "patch {" $TEST_ROOT/manifest2
 | 
					$NIX_BIN_DIR/generate-patches.pl $TEST_ROOT/cache2 $TEST_ROOT/patches \
 | 
				
			||||||
 | 
					    file://$TEST_ROOT/patches $TEST_ROOT/manifest2 $TEST_ROOT/manifest3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Get rid of version 2.
 | 
					grep -q "patch {" $TEST_ROOT/manifest3
 | 
				
			||||||
$nixstore --delete $out2
 | 
					 | 
				
			||||||
! test -e $out2
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Pull the manifest containing the patch.
 | 
					# Get rid of versions 2 and 3.
 | 
				
			||||||
 | 
					$nixstore --delete $out2 $out3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Pull the manifest containing the patches.
 | 
				
			||||||
clearManifests
 | 
					clearManifests
 | 
				
			||||||
$NIX_BIN_DIR/nix-pull file://$TEST_ROOT/manifest2
 | 
					$NIX_BIN_DIR/nix-pull file://$TEST_ROOT/manifest3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# To make sure that we're using the patch, delete the full NARs.
 | 
					# Make sure that the download size prediction uses the patches rather
 | 
				
			||||||
rm -f $TEST_ROOT/cache2/*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Make sure that the download size prediction uses the patch rather
 | 
					 | 
				
			||||||
# than the full download.
 | 
					# than the full download.
 | 
				
			||||||
$nixbuild -o $RESULT binary-patching.nix --arg version 2 --dry-run 2>&1 | grep -q "0.01 MiB"
 | 
					$nixbuild -o $RESULT binary-patching.nix --arg version 3 --dry-run 2>&1 | grep -q "0.01 MiB"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Now rebuild it.  This should use the patch generated above.
 | 
					# Now rebuild it.  This should use the two patches generated above.
 | 
				
			||||||
$nixbuild -o $RESULT binary-patching.nix --arg version 2
 | 
					rm -f $TEST_ROOT/var/log/nix/downloads
 | 
				
			||||||
 | 
					$nixbuild -o $RESULT binary-patching.nix --arg version 3
 | 
				
			||||||
 | 
					rm $RESULT
 | 
				
			||||||
 | 
					[ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 2 ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Add a patch from version 1 directly to version 3.
 | 
				
			||||||
 | 
					$NIX_BIN_DIR/generate-patches.pl $TEST_ROOT/cache2 $TEST_ROOT/patches \
 | 
				
			||||||
 | 
					    file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Rebuild version 3.  This should use the direct patch rather than the
 | 
				
			||||||
 | 
					# sequence of two patches.
 | 
				
			||||||
 | 
					$nixstore --delete $out2 $out3
 | 
				
			||||||
 | 
					clearManifests
 | 
				
			||||||
 | 
					rm $TEST_ROOT/var/log/nix/downloads
 | 
				
			||||||
 | 
					$NIX_BIN_DIR/nix-pull file://$TEST_ROOT/manifest3
 | 
				
			||||||
 | 
					$nixbuild -o $RESULT binary-patching.nix --arg version 3
 | 
				
			||||||
 | 
					[ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 1 ]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue