Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 623

Show
Ignore:
Timestamp:
08/22/10 08:27:19 (14 years ago)
Author:
braddr
Message:

Add support for custom post-test scripts.
Add a test that uses -profile and validate that it emits the correct .def file and at least something in the .log file

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/test/do_test.sh

    r576 r623  
    3535    if [ "${input_dir}" != "fail_compilation" ]; then 
    3636        p_args="${ARGS}" 
    3737    fi 
    3838else 
    3939    p_args="${p_args/*PERMUTE_ARGS:*( )/}" 
    4040fi 
    4141 
    4242e_args=`grep EXECUTE_ARGS  ${input_file} | tr -d \\\\r\\\\n` 
    4343if [ ! -z "$e_args" ]; then 
    4444    e_args="${e_args/*EXECUTE_ARGS:*( )/}" 
    4545fi 
    4646 
    4747extra_sources=`grep EXTRA_SOURCES ${input_file} | tr -d \\\\r\\\\n` 
    4848if [ ! -z "${extra_sources}" ]; then 
    4949    extra_sources=(${extra_sources/*EXTRA_SOURCES:*( )/}) 
    5050    extra_files="${extra_sources[*]/imports/${input_dir}/imports}" 
    5151fi 
    5252 
    5353grep -q COMPILE_SEPARATELY ${input_file} 
    5454separate=$? 
     55 
     56post_script=`grep POST_SCRIPT ${input_file} | tr -d \\\\r\\\\n` 
     57if [ ! -z "${post_script}" ]; then 
     58    post_script="${post_script/*POST_SCRIPT:*( )/}" 
     59fi 
    5560 
    5661if [ "${input_dir}" != "runnable" ]; then 
    5762    extra_compile_args="-c" 
    5863fi 
    5964 
    6065if [ "${input_dir}" != "fail_compilation" ]; then 
    6166    expect_compile_rc=1 
    6267else 
    6368    expect_compile_rc=0 
    6469fi 
    6570 
    6671 
    6772printf " ... %-25s %s%s(%s)\n" "${input_file}" "${r_args}" "${extra_space}" "${p_args}" 
    6873 
    6974${RESULTS_DIR}/combinations ${p_args} | while read x; do 
    7075 
    7176    if [ ${separate} -ne 0 ]; then 
    7277        echo ${DMD} -I${input_dir} ${r_args} $x -od${output_dir} -of${test_app} ${extra_compile_args} ${input_file} ${extra_files} >> ${output_file} 
    7378        ${DMD} -I${input_dir} ${r_args} $x -od${output_dir} -of${test_app} ${extra_compile_args} ${input_file} ${extra_files} >> ${output_file} 2>&1 
    7479        if [ $? -eq ${expect_compile_rc} ]; then 
     
    95100            echo ${DMD} -od${output_dir} -of${test_app} ${test_app}.o ${ofiles[*]} >> ${output_file} 
    96101            ${DMD} -od${output_dir} -of${test_app} ${test_app}.o ${ofiles[*]} >> ${output_file} 2>&1 
    97102            if [ $? -eq ${expect_compile_rc} ]; then 
    98103                cat ${output_file} 
    99104                rm -f ${output_file} 
    100105                exit 1 
    101106            fi 
    102107        fi 
    103108    fi 
    104109 
    105110    if [ "${input_dir}" = "runnable" ]; then 
    106111        echo ${test_app} ${e_args} >> ${output_file} 
    107112        ${test_app} ${e_args} >> ${output_file} 2>&1 
    108113        if [ $? -ne 0 ]; then 
    109114            cat ${output_file} 
    110115            rm -f ${output_file} 
    111116            exit 1 
    112117        fi 
    113118    fi 
    114119 
     120    if [ ! -z ${post_script} ]; then 
     121        echo "Executing post-test script: ${post_script}" >> ${output_file} 
     122        ${post_script} >> ${output_file} 2>&1 
     123        if [ $? -ne 0 ]; then 
     124            cat ${output_file} 
     125            rm -f ${output_file} 
     126            exit 1 
     127        fi 
     128    fi 
     129 
    115130    rm -f ${test_app} ${test_app}.o ${ofiles[*]} 
    116131 
    117132    echo >> ${output_file} 
    118133done 
  • trunk/test/Makefile

    r574 r623  
    1212#    quick:              run all tests with no default permuted args 
    1313#                        (individual test specified options still honored) 
    1414# 
    1515#    clean:              remove all temporary or result files from prevous runs 
    1616# 
    1717# 
    1818# In-test variables: 
    1919# 
    2020#   COMPILE_SEPARATELY:  if present, forces each .d file to compile separately and linked 
    2121#                        together in an extra setp. 
    2222#                        default: (none, aka compile/link all in one step) 
    2323# 
    2424#   EXECUTE_ARGS:        parameters to add to the execution of the test 
    2525#                        default: (none) 
    2626# 
    2727#   EXTRA_SOURCES:       list of extra files to build and link along with the test 
    2828#                        default: (none) 
    2929# 
    3030#   PERMUTE_ARGS:        the set of arguments to permute in multiple $(DMD) invocations 
    3131#                        default: the make variable ARGS (see below) 
     32# 
     33#   POST_SCRIPT:         name of script to execute after test run 
     34#                        default: (none) 
    3235# 
    3336#   REQUIRED_ARGS:       arguments to add to the $(DMD) command line 
    3437#                        default: (none) 
    3538 
    3639SHELL=/bin/bash 
    3740QUIET=@ 
    3841export DMD=../src/dmd 
    3942export RESULTS_DIR=test_results 
    4043export ARGS=-inline -release -gc -O -unittest -fPIC 
    4144 
    4245runnable_tests=$(wildcard runnable/*.d) 
    4346runnable_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(runnable_tests))) 
    4447 
    4548compilable_tests=$(wildcard compilable/*.d) 
    4649compilable_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(compilable_tests))) 
    4750 
    4851fail_compilation_tests=$(wildcard fail_compilation/*.d) 
    4952fail_compilation_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(fail_compilation_tests))) 
    5053 
    5154$(RESULTS_DIR)/runnable/%.d.out: runnable/%.d $(RESULTS_DIR)/.created $(RESULTS_DIR)/combinations $(DMD)