From 1aebc2c2ef767a8ad007c2e10ed263cb52b794dd Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 26 Oct 2026 15:41:40 -0500 Subject: [PATCH] Switch testing->testcmd --- tests/sed.test | 93 ++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 52 deletions(-) diff --git a/tests/sed.test b/tests/sed.test index 06fec59b..1790c7d2 100755 --- a/tests/sed.test +++ b/tests/sed.test @@ -78,50 +78,41 @@ testcmd "c multiple continuation" "-e 'c\\' -e 'two\\' -e ''" "two\n\n" "" \ "hello" testcmd 'multiline continuations' '-e c\\ -e line1\\ -e line2' 'line1\nline2\n'\ '' 'one\n' -toyonly testing "c empty continuation" "sed -e 'c\\'" "\n" "" "hello" -testing "D further processing depends on whether line is blank" \ - "sed -e '/one/,/three/{' -e 'i meep' -e'N;2D;}'" \ +toyonly testcmd "c empty continuation" "-e 'c\\'" "\n" "" "hello" +testcmd "D further processing depends on whether line is blank" \ + "-e '/one/,/three/{' -e 'i meep' -e'N;2D;}'" \ "meep\nmeep\ntwo\nthree\n" "" "one\ntwo\nthree\n" -testing 'newline staying away' 'sed s/o/x/' 'xne\ntwx' '' 'one\ntwo' - -# Why on _earth_ is this not an error? There's a \ with no continuation! -#testing 'sed what, _really_?' 'sed -e a\\ && echo yes really' \ -# 'one\nyes really\n' '' 'one\n' +testcmd 'newline staying away' 's/o/x/' 'xne\ntwx' '' 'one\ntwo' # all the s/// test -testing "match empty line" "sed -e 's/^\$/@/'" "@\n" "" "\n" +testcmd "match empty line" "-e 's/^\$/@/'" "@\n" "" "\n" -testing '\1' "sed 's/t\\(w\\)o/za\\1py/'" "one\nzawpy\nthree" "" \ - "one\ntwo\nthree" -testing '\1 p' "sed 's/t\\(w\\)o/za\\1py/p'" "one\nzawpy\nzawpy\nthree" \ +testcmd '\1' "'s/t\\(w\\)o/za\\1py/'" "one\nzawpy\nthree" "" "one\ntwo\nthree" +testcmd '\1 p' "'s/t\\(w\\)o/za\\1py/p'" "one\nzawpy\nzawpy\nthree" \ "" "one\ntwo\nthree" -testing '\1 no newline' "sed 's/t\\(w\\)o/za\\1py/'" "one\nzawpy" "" \ +testcmd '\1 no newline' "'s/t\\(w\\)o/za\\1py/'" "one\nzawpy" "" "one\ntwo" +testcmd '\1 p no newline' "'s/t\\(w\\)o/za\\1py/p'" "one\nzawpy\nzawpy" "" \ + "one\ntwo" +testcmd '-n s//\1/p' "-n 's/t\\(w\\)o/za\\1py/p'" "zawpy" "" "one\ntwo" +testcmd '-n s//\1/p no newline' "-n 's/t\\(w\\)o/za\\1py/p'" "zawpy" "" \ "one\ntwo" -testing '\1 p no newline' "sed 's/t\\(w\\)o/za\\1py/p'" \ - "one\nzawpy\nzawpy" "" "one\ntwo" -testing '-n s//\1/p' "sed -n 's/t\\(w\\)o/za\\1py/p'" "zawpy" "" "one\ntwo" -testing '-n s//\1/p no newline' "sed -n 's/t\\(w\\)o/za\\1py/p'" "zawpy" \ - "" "one\ntwo" -testing 'backref error' \ - "sed 's/w/ale \2 ha/' >/dev/null 2>/dev/null || echo no" \ +testcmd 'backref error' "'s/w/ale \2 ha/' >/dev/null 2>/dev/null || echo no" \ "no\n" "" "one\ntwo\nthree" -testing 'empty match after nonempty match' "sed -e 's/a*/c/g'" 'cbcncgc' \ - '' 'baaang' -testing 'empty match' "sed -e 's/[^ac]*/A/g'" 'AaAcA' '' 'abcde' -testing 's///#comment' "sed -e 's/TWO/four/i#comment'" "one\nfour\nthree" \ - "" "one\ntwo\nthree" -testing 's///num off end' 'sed -e s/e//2' 'e\n' '' 'e\n' +testcmd 'empty match after nonempty match' "'s/a*/c/g'" 'cbcncgc' '' 'baaang' +testcmd 'empty match' "-e 's/[^ac]*/A/g'" 'AaAcA' '' 'abcde' +testcmd 's///#comment' "'s/TWO/four/i#comment'" "one\nfour\nthree" "" \ + "one\ntwo\nthree" +testcmd 's///num off end' 's/e//2' 'e\n' '' 'e\n' -testing 'N flushes pending a and advances match counter' \ - "sed -e 'a woo' -e 'N;\$p'" 'woo\none\ntwo\none\ntwo' "" 'one\ntwo' -testing "delimiter in regex [char range] doesn't count" "sed -e 's/[/]//'" \ +testcmd 'N flushes pending a and advances match counter' \ + "-e 'a woo' -e 'N;\$p'" 'woo\none\ntwo\none\ntwo' "" 'one\ntwo' +testcmd "delimiter in regex [char range] doesn't count" "'s/[/]//'" \ "onetwo\n" "" 'one/two\n' -testing "delete regex range start line after trigger" \ - "sed -e '/one/,/three/{' -e 'i meep' -e '1D;}'" \ +testcmd "delete regex range start line after trigger" \ + "-e '/one/,/three/{' -e 'i meep' -e '1D;}'" \ "meep\nmeep\ntwo\nmeep\nthree" "" "one\ntwo\nthree" -testing "blank pattern repeats last pattern" \ - "sed -e '/^three/s//abc&def/'" \ +testcmd "blank pattern repeats last pattern" "'/^three/s//abc&def/'" \ "one two three\nabcthreedef four five\nfive six seven\n" "" \ "one two three\nthree four five\nfive six seven\n" @@ -130,43 +121,41 @@ testcmd "interleave -e and -f" "-e 'a abc' -f input -e 'a ghi'" \ # Different ways of parsing line continuations -testing "" "sed -e '1a\' -e 'huh'" "meep\nhuh\n" "" "meep" -testing "" "sed -f input" "blah\nboom\n" '1a\\\nboom' 'blah' -testing "" "sed -f - input" "blah\nboom\n" 'blah' '1a\\\nboom' -testing "" "sed '1a\ -hello'" "merp\nhello\n" "" "merp" +testcmd "" "-e '1a\' -e 'huh'" "meep\nhuh\n" "" "meep" +testcmd "" "-f input" "blah\nboom\n" '1a\\\nboom' 'blah' +testcmd "" "-f - input" "blah\nboom\n" 'blah' '1a\\\nboom' +testcmd "newline in pattern" $'\'1a\\\nhello\'' "merp\nhello\n" "" "merp" -testing "" "sed -e '/x/c\' -e 'y'" 'y\n' '' 'x\n' -testing "" "sed -e 's/a[([]*b/X/'" 'X' '' 'a[(b' -toyonly testing "" "sed 'y/a\\bc/de\f/'" "db\f" "" "abc" -testing "[a-a] (for perl)" "sed '"'s/\([^a-zA-Z0-9.:_\-\/]\)/\\\1/g'"'" \ +testcmd "" "-e '/x/c\' -e 'y'" 'y\n' '' 'x\n' +testcmd "" "-e 's/a[([]*b/X/'" 'X' '' 'a[(b' +toyonly testcmd "" "'y/a\\bc/de\f/'" "db\f" "" "abc" +testcmd "[a-a] (for perl)" \''s/\([^a-zA-Z0-9.:_\-\/]\)/\\\1/g'"'" \ 'he\ llo' "" "he llo" # Debian bug https://bugs.debian.org/635570 added code to ensure a file # ends with a newline via "sed -e '$a\'". Apparently all a\ with no additional # pattern lines after it does (other than making posix throw up) is # flush the pending newline as _if_ it had added another line. *shrug* Ok? -testing "trailing a\ (for debian)" "sed 'a\\'" "hello\n" "" "hello" +testcmd "trailing a\ (for debian)" "'a\\'" "hello\n" "" "hello" # You have to match the first line of a range in order to activate # the range, numeric and ascii work the same way -toyonly testing "skip start of range" "sed -e n -e '1,2s/b/c/'" "a\nb\n" "" "a\nb\n" -testing "range +1" "sed -ne '/blah/,+1p'" "blah\n6\n" "" \ +toyonly testcmd "skip start of range" "-e n -e '1,2s/b/c/'" "a\nb\n" "" "a\nb\n" +testcmd "range +1" "-ne '/blah/,+1p'" "blah\n6\n" "" \ "1\n2\n3\n4\n5\nblah\n6\n7\n8\n9\n" -testing "range +0" "sed -ne '/blah/,+0p'" "blah\n" "" \ +testcmd "range +0" "-ne '/blah/,+0p'" "blah\n" "" \ "1\n2\n3\n4\n5\nblah\n6\n7\n8\n9\n" -testing "range +3" "sed -ne '2,+3p'" "2\n3\n4\n5\n" "" \ +testcmd "range +3" "-ne '2,+3p'" "2\n3\n4\n5\n" "" \ "1\n2\n3\n4\n5\nblah\n6\n7\n8\n9\n" -testing "not -s" "sed -n 1p input -" "one" "one" "two" -testing "-s" "sed -sn 1p input -" "one\ntwo" "one\n" "two" +testcmd "not -s" "-n 1p input -" "one" "one" "two" +testcmd "-s" "-sn 1p input -" "one\ntwo" "one\n" "two" -testing "bonus backslashes" \ - "sed -e 'a \l \x\' -e \"\$(echo -e 'ab\\\nc')\"" \ +testcmd "bonus backslashes" "-e 'a \l \x\' -e \"\$(echo -e 'ab\\\nc')\"" \ "hello\nl x\nab\nc\n" "" "hello\n" # toybox saying "no }" here broke the AOSP build. -testing "end b with }" "sed -n '/START/{:a;n;/END/q;p;ba}'" "b\nc\n" \ +testcmd "end b with }" "-n '/START/{:a;n;/END/q;p;ba}'" "b\nc\n" \ "" "a\nSTART\nb\nc\nEND\nd" testcmd '-z' '-z "s/\n/-/g"' "a-b-c" "" "a\nb\nc" -- 2.39.5