mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 22:22:45 +00:00 
			
		
		
		
	 8fc862f710
			
		
	
	
		8fc862f710
		
	
	
	
	
		
			
			Also make them runnable anywhere. Previously they required $PWD to be the directory containing test-commons.inc, and for $PWD to be writable.
		
			
				
	
	
		
			39 lines
		
	
	
	
		
			844 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
	
		
			844 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/bin/sh
 | |
| 
 | |
| source $(dirname "$0")/test-commons.inc
 | |
| 
 | |
| setopt --verbose
 | |
| 
 | |
| rm -rf shell-test
 | |
| mkdir shell-test
 | |
| cd shell-test
 | |
| 
 | |
|     # Simple sequence (grouping)
 | |
|     { echo test > testfile }
 | |
|     if not test "$(cat testfile)" = "test" {
 | |
|         fail cannot write to file in subshell
 | |
|     }
 | |
| 
 | |
|     # Simple sequence - many commands
 | |
|     { echo test1 > testfile; echo test2 > testfile }
 | |
|     if not test "$(cat testfile)" = "test2" {
 | |
|         fail cannot write to file in subshell 2
 | |
|     }
 | |
| 
 | |
|     # Does it exit with the last exit code?
 | |
|     { test -z "a" }
 | |
|     exitcode=$?
 | |
|     if not test "$exitcode" -eq 1 {
 | |
|         fail exits with $exitcode when it should exit with 1
 | |
|     }
 | |
| 
 | |
|     { test -z "a" || echo test }
 | |
|     exitcode=$?
 | |
|     if not test "$exitcode" -eq 0 {
 | |
|         fail exits with $exitcode when it should exit with 0
 | |
|     }
 | |
| 
 | |
| cd ..
 | |
| rm -rf shell-test
 | |
| 
 | |
| echo PASS
 |