Add tests
This commit is contained in:
		
							parent
							
								
									f6fc817e84
								
							
						
					
					
						commit
						0976f04505
					
				
							
								
								
									
										9
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
build:
 | 
			
		||||
 | 
			
		||||
install:
 | 
			
		||||
	mkdir -p $(PREFIX)/bin $(PREFIX)/share
 | 
			
		||||
	cp direnv-cache $(PREFIX)/bin
 | 
			
		||||
	cp direnvrc $(PREFIX)/share
 | 
			
		||||
 | 
			
		||||
check:
 | 
			
		||||
	term-test -s tests
 | 
			
		||||
							
								
								
									
										16
									
								
								default.nix
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								default.nix
									
									
									
									
									
								
							@ -1,3 +1,13 @@
 | 
			
		||||
{ pkgs ? import <nixpkgs> {} }:
 | 
			
		||||
(pkgs.writers.writeBashBin "direnv-cache" ./direnv-cache).overrideAttrs
 | 
			
		||||
  (o: { passthru = { direnvrc = ./direnvrc; }; })
 | 
			
		||||
{ stdenv, direnv, term-test }:
 | 
			
		||||
 | 
			
		||||
stdenv.mkDerivation {
 | 
			
		||||
  name = "direnv-cache";
 | 
			
		||||
  src = ./.;
 | 
			
		||||
  propagatedBuildInputs = [ direnv ];
 | 
			
		||||
  installPhase = ''
 | 
			
		||||
    make install PREFIX=$out
 | 
			
		||||
  '';
 | 
			
		||||
  checkInputs = [ term-test ];
 | 
			
		||||
  doCheck = true;
 | 
			
		||||
  passthru = { direnvrc = ./direnvrc; };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								shell.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								shell.nix
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
{ pkgs ? import <nixpkgs> {} }:
 | 
			
		||||
pkgs.callPackage ./. {}
 | 
			
		||||
							
								
								
									
										33
									
								
								tests/test_direnv_stable_behavior
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								tests/test_direnv_stable_behavior
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
			
		||||
# -*- mode: sh -*-
 | 
			
		||||
 | 
			
		||||
function initDirenv {
 | 
			
		||||
    # direnv needs a writable home:
 | 
			
		||||
    run "export HOME=$(pwd)"
 | 
			
		||||
    run 'eval "$(direnv hook bash)"'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function test_simpleEnvrcWorks {
 | 
			
		||||
    initDirenv
 | 
			
		||||
 | 
			
		||||
    writeFile .envrc <<EOF
 | 
			
		||||
          export FOO=bar
 | 
			
		||||
EOF
 | 
			
		||||
    run "direnv allow"
 | 
			
		||||
    assert "$(getEnv FOO)" == bar
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function test_direnvExecRunsInCleanEnv {
 | 
			
		||||
    initDirenv
 | 
			
		||||
 | 
			
		||||
    run "export FOO=baz"
 | 
			
		||||
 | 
			
		||||
    writeFile .envrc <<EOF
 | 
			
		||||
          export FOO=bar
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
    run "direnv allow"
 | 
			
		||||
    assert "$(getEnv FOO)" == bar
 | 
			
		||||
    #captureShell 'echo $FOO'
 | 
			
		||||
    #captureShell 'direnv exec /proc env | grep FOO'
 | 
			
		||||
    assert "$(captureShell 'direnv exec /proc env | grep FOO')" == "FOO=baz"
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user