#!/bin/sh global test_description := '"Test the svn importer's input handling routines. These tests provide some simple checks that the line_buffer API behaves as advertised. While at it, check that input of newlines and null bytes are handled correctly. '" source ./test-lib.sh test_expect_success 'hello world' ' echo ">HELLO" >expect && test-line-buffer <<-\EOF >actual && binary 6 HELLO EOF test_cmp expect actual ' test_expect_success '0-length read, send along greeting' ' echo ">HELLO" >expect && test-line-buffer <<-\EOF >actual && binary 0 copy 6 HELLO EOF test_cmp expect actual ' test_expect_success !MINGW 'read from file descriptor' ' rm -f input && echo hello >expect && echo hello >input && echo copy 6 | test-line-buffer "&4" 4actual && test_cmp expect actual ' test_expect_success 'skip, copy null byte' ' echo Q | q_to_nul >expect && q_to_nul <<-\EOF | test-line-buffer >actual && skip 2 Q copy 2 Q EOF test_cmp expect actual ' test_expect_success 'read null byte' ' echo ">QhelloQ" | q_to_nul >expect && q_to_nul <<-\EOF | test-line-buffer >actual && binary 8 QhelloQ EOF test_cmp expect actual ' test_expect_success 'long reads are truncated' ' echo ">foo" >expect && test-line-buffer <<-\EOF >actual && binary 5 foo EOF test_cmp expect actual ' test_expect_success 'long copies are truncated' ' printf "%s\n" ">" foo >expect && test-line-buffer <<-\EOF >actual && binary 1 copy 5 foo EOF test_cmp expect actual ' test_expect_success 'long binary reads are truncated' ' echo ">foo" >expect && test-line-buffer <<-\EOF >actual && binary 5 foo EOF test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (DQ ("Test the svn importer's input handling routines.\n") ("\n") ("These tests provide some simple checks that the line_buffer API\n") ("behaves as advertised.\n") ("\n") ("While at it, check that input of newlines and null bytes are handled\n") ("correctly.\n") ) } spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"hello world">)} { (SQ <"\n"> <"\techo \">HELLO\" >expect &&\n"> <"\ttest-line-buffer <<-\\EOF >actual &&\n"> <"\tbinary 6\n"> <"\tHELLO\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"0-length read, send along greeting">)} { (SQ <"\n"> <"\techo \">HELLO\" >expect &&\n"> <"\ttest-line-buffer <<-\\EOF >actual &&\n"> <"\tbinary 0\n"> <"\tcopy 6\n"> <"\tHELLO\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(KW_Bang "!") (MINGW)} {(SQ <"read from file descriptor">)} { (SQ <"\n"> <"\trm -f input &&\n"> <"\techo hello >expect &&\n"> <"\techo hello >input &&\n"> <"\techo copy 6 |\n"> <"\ttest-line-buffer \"&4\" 4actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"skip, copy null byte">)} { (SQ <"\n"> <"\techo Q | q_to_nul >expect &&\n"> <"\tq_to_nul <<-\\EOF | test-line-buffer >actual &&\n"> <"\tskip 2\n"> <"\tQ\n"> <"\tcopy 2\n"> <"\tQ\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"read null byte">)} { (SQ <"\n"> <"\techo \">QhelloQ\" | q_to_nul >expect &&\n"> <"\tq_to_nul <<-\\EOF | test-line-buffer >actual &&\n"> <"\tbinary 8\n"> <"\tQhelloQ\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"long reads are truncated">)} { (SQ <"\n"> <"\techo \">foo\" >expect &&\n"> <"\ttest-line-buffer <<-\\EOF >actual &&\n"> <"\tbinary 5\n"> <"\tfoo\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"long copies are truncated">)} { (SQ <"\n"> <"\tprintf \"%s\\n\" \">\" foo >expect &&\n"> <"\ttest-line-buffer <<-\\EOF >actual &&\n"> <"\tbinary 1\n"> <"\n"> <"\tcopy 5\n"> <"\tfoo\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"long binary reads are truncated">)} { (SQ <"\n"> <"\techo \">foo\" >expect &&\n"> <"\ttest-line-buffer <<-\\EOF >actual &&\n"> <"\tbinary 5\n"> <"\tfoo\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )