# file      : tests/test/script/common.testscript
# license   : MIT; see accompanying LICENSE file

# Commonly-used build system test project setup and driver command line
# (test module using testscript tests).
#

+mkdir build
+cat <<"EOI" >=build/bootstrap.build
project = test
amalgamation =
subprojects =

using test
EOI

# We assume the specified target if any is in out_base which would be two
# levels up from our working directory.
#
+ife! $target
{
  cat <<"EOI" >=build/root.build
  target = \$src_root/../../$string([name] $target)
  testscript{*}: test = \$target
  EOI
}

# The "cat & build" setup: first cat ($c) the testscript, then run build ($b)
# which will execute the testscript. We have to quote stdin because of the
# command line re-expansion.
#
# Note that the buildfile is clever hack that relies on the first target
# automatically becoming dir{./}'s prerequisite.
#
c = [cmdline] cat >=testscript

# @@ TMP Drop testscript.syntax assignment when support for syntax 1 is
#        dropped (see libbuild2/script/parser.hxx for details).
#
b = [cmdline] $0 --no-default-options --serial-stop --quiet --buildfile - test \
<"'testscript{testscript}: \$target$\ntestscript{testscript}: testscript.syntax = 2'" \
&?test/***
