From 4eb0d3bc26a1dcf94132e69e1194d63938d7cdff Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 5 Oct 2011 09:03:51 +0200 Subject: [PATCH] Add tests for tesh sorting and filtering of ouptut. --- buildtools/Cmake/AddTests.cmake | 2 +- tools/tesh/basic.tesh | 14 +++++++++ tools/tesh/basic2.tesh | 55 +++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tools/tesh/basic2.tesh diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index 4989ffd14d..06b05c27da 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -24,7 +24,7 @@ INCLUDE(CTest) ENABLE_TESTING() if(NOT enable_memcheck) -ADD_TEST(tesh-self-basic ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd "${CMAKE_HOME_DIRECTORY}/tools/tesh" basic.tesh) +ADD_TEST(tesh-self-basic ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --setenv bindir=${CMAKE_BINARY_DIR}/bin --cd "${CMAKE_HOME_DIRECTORY}/tools/tesh" basic.tesh) ADD_TEST(tesh-self-cd ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/cd.tesh) ADD_TEST(tesh-self-IO-broken-pipe ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd "${CMAKE_HOME_DIRECTORY}/tools/tesh" IO-broken-pipe.tesh) ADD_TEST(tesh-self-IO-orders ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/IO-orders.tesh) diff --git a/tools/tesh/basic.tesh b/tools/tesh/basic.tesh index fd7de37e71..d26a68ee98 100644 --- a/tools/tesh/basic.tesh +++ b/tools/tesh/basic.tesh @@ -29,3 +29,17 @@ $ wc -l tmp_fich > 4 tmp_fich $ rm tmp_fich + +$ ${bindir:=.}/tesh --enable-coverage --log='log.thresh:info tesh.fmt:%m%n' basic2.tesh +> Enable coverage +> Test suite `basic2' +> [basic2:3] Test sorting and filtering of output +> [basic2:5] printf 'a\\nb\\nc\\nd\\n' +> [basic2:11] printf 'a\\nb\\nc\\nd' +> [basic2:18] printf 'c\\nd\\nb\\na\\n' +> [basic2:25] printf 'c\\nd\\nb\\na' +> [basic2:31] printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz\\n' +> [basic2:37] printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz' +> [basic2:44] printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz\\n' +> [basic2:51] printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz' +> Test suite `basic2' OK diff --git a/tools/tesh/basic2.tesh b/tools/tesh/basic2.tesh new file mode 100644 index 0000000000..9e08b11561 --- /dev/null +++ b/tools/tesh/basic2.tesh @@ -0,0 +1,55 @@ +#! ./tesh + +p Test sorting and filtering of output + +$ printf 'a\\nb\\nc\\nd\\n' +> a +> b +> c +> d + +$ printf 'a\\nb\\nc\\nd' +> a +> b +> c +> d + +! output sort +$ printf 'c\\nd\\nb\\na\\n' +> a +> b +> c +> d + +! output sort +$ printf 'c\\nd\\nb\\na' +> a +> b +> c +> d + +$ printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz\\n' +> a +> b +> c +> d + +$ printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz' +> a +> b +> c +> d + +! output sort +$ printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz\\n' +> a +> b +> c +> d + +! output sort +$ printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz' +> a +> b +> c +> d -- 2.20.1