[Toybox] Test plumbing on Android question.

Rob Landley rob at landley.net
Mon Mar 27 06:14:08 PDT 2023


I added ls --sort but not the tests for it yet, and I'm trying to clean up
tests/ls.test so each test doesn't have to cd into a subdirectory and cd ..
again at the end, and the _reason_ it's doing this is so "expected" and "actual"
(argument $3 and where the command's output is redirected from, so we can diff
them) aren't in the current directory, and thus don't show up in each ls test's
output. (The "input" file is only created when argument 4 isn't blank, that one
should already be ok?)

scripts/test.sh sets up generated/testdir/testdir, and uses that middle
directory as the install location for the binaries it's testing, which goes at
the start of the $PATH, and I _think_ I can just move "expected" and "actual" up
into there without too much trouble...

Except Android's test plumbing doesn't use my scripts/test.sh, just
scripts/runtest.sh, so don't know if ../expected and ../actual from the current
testing directory are allowable there?

Basically I want to do this:

--- a/scripts/runtest.sh
+++ b/scripts/runtest.sh
@@ -132,15 +132,15 @@ testing()
     return 0
   fi

-  echo -ne "$3" > expected
+  echo -ne "$3" > ../expected
   [ ! -z "$4" ] && echo -ne "$4" > input || rm -f input
-  echo -ne "$5" | ${EVAL:-eval --} "$2" > actual
+  echo -ne "$5" | ${EVAL:-eval --} "$2" > ../actual
   RETVAL=$?

   # Catch segfaults
   [ $RETVAL -gt 128 ] &&
     echo "exited with signal (or returned $RETVAL)" >> actual
-  DIFF="$(diff -au${NOSPACE:+w} expected actual)"
+  DIFF="$(cd ..; diff -au${NOSPACE:+w} expected actual)"
   [ -z "$DIFF" ] && do_pass || VERBOSE=all do_fail
   if ! verbose_has quiet && { [ -n "$DIFF" ] || verbose_has spam; }
   then
@@ -150,7 +150,7 @@ testing()
   fi

   [ -n "$DIFF" ] && ! verbose_has all && exit 1
-  rm -f input expected actual
+  rm -f input ../expected ../actual

   [ -n "$DEBUG" ] && set +x


Rob


More information about the Toybox mailing list