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

# Commonly-used build system test project setup and driver command line.
#

# If the includer indicated that no cross-testing should be supported, then
# use the build system driver that is building, not the one being built.
#
# In many cases expecting a cross-compiled driver to perform a native build
# under emulation is pushing things a bit too far. Plus, we have no way of
# knowing the native compiler name/path.
#
# So the idea here is to test cross-compilation with the understanding that
# the build system driver we are testing is not the one being cross-compiled
# but rather the one doing the cross-compilation.
#
ifn $crosstest
  crosstest = true

if (!$crosstest && $test.target != $build.host)
  test = $recall($build.path)

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

# Note that we use the single-argument form for options, so that the tests can
# easily amend them or filter them out, if required.
#
test.options += --no-default-options --serial-stop --quiet

# By default read stdin for the buildfile.
#
if ($null($buildfile) || !$buildfile)
  test.options += --buildfile=-

# By default just load the buildfile.
#
ifn $test.arguments
  test.arguments = noop
