test: cleaner tests for CSV parser proposal
This commit is contained in:
		
							parent
							
								
									881422cd0f
								
							
						
					
					
						commit
						9440664fc4
					
				@ -160,6 +160,25 @@ $  printf 'fields account1, date, description, amount-in, amount-out\ndate-forma
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
>=0
 | 
					>=0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 16. use a script for cleaner csv tests?
 | 
				
			||||||
 | 
					<
 | 
				
			||||||
 | 
					myacct,10/2009/09,Flubber Co,50,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RULES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fields account1, date, description, amount-in, amount-out
 | 
				
			||||||
 | 
					date-format %d/%Y/%m
 | 
				
			||||||
 | 
					currency $
 | 
				
			||||||
 | 
					if Flubber
 | 
				
			||||||
 | 
					  account1  assets:%account1
 | 
				
			||||||
 | 
					  amount-in  (%amount-in)
 | 
				
			||||||
 | 
					$  ./hledger-csv
 | 
				
			||||||
 | 
					2009/09/10 Flubber Co
 | 
				
			||||||
 | 
					    assets:myacct             $-50
 | 
				
			||||||
 | 
					    income:unknown
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					>=0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# . TODO: without --separator gives obscure error
 | 
					# . TODO: without --separator gives obscure error
 | 
				
			||||||
#   |
 | 
					#   |
 | 
				
			||||||
# 1 | 10/2009/09;Flubber Co🎅;50;
 | 
					# 1 | 10/2009/09;Flubber Co🎅;50;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										15
									
								
								tests/hledger-csv
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								tests/hledger-csv
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# This scripts expects stdin formatted like this:
 | 
				
			||||||
 | 
					# <multi-line csv file>
 | 
				
			||||||
 | 
					# RULES
 | 
				
			||||||
 | 
					# <multi-line rules>
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					awk -vCSV="t.$$.csv" -vRULES="t.$$.csv.rules" '
 | 
				
			||||||
 | 
					BEGIN{output=CSV}
 | 
				
			||||||
 | 
					/^RULES/{output=RULES}
 | 
				
			||||||
 | 
					!/^RULES/{print $0 >output}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					trap "rm -f t.$$.csv t.$$.csv.rules" EXIT ERR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					hledger -f csv:t.$$.csv --rules-file t.$$.csv.rules print
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user