#!/bin/bash

. common


#---------------------------------------------
# test MST_AM_OVERRIDE_VAR

test_initialize
test_result_hook result_hook


#---------------
# test mst_program_prefix

test_begin_subtests

prefix='MST_AM_OVERRIDE_VAR'
output_file="$(testpfx)_output"

echo "@AM_CXXFLAGS@" > $(testpfx)_am_cxxflags.in
echo "@CXXFLAGS@" > $(testpfx)_cxxflags.in

config_str "$prefix"				\
    'MST_AM_INIT'				\
    'MST_AM_OVERRIDE_VAR([CXXFLAGS])'		\
    'AC_SUBST([CXXFLAGS])'			\
    "AC_CONFIG_FILES([$(testpfx)_am_cxxflags $(testpfx)_cxxflags])"

run_test "$prefix" CXXFLAGS=--my-cxxflags
if [ $test_status -eq 0 ]; then
    output=$(< $(testpfx)_am_cxxflags)
    test_is "$output" '--my-cxxflags' "$prefix: AM_CXXFLAGS is set"
    output=$(< $(testpfx)_cxxflags)
    test_is "$output" '' "$prefix: CXXFLAGS is empty"
else
    test_skip "$prefix: configure failed; skipping output check" 1
fi

test_end_subtests

test_summary
test_exit
