subproject libs/python/test ;

# bring in the rules for python
SEARCH on <module@>python.jam = $(BOOST_BUILD_PATH) ;
include <module@>python.jam ;

local PYTHON_V1_PROPERTIES = $(PYTHON_PROPERTIES) ;
local PYTHON_PROPERTIES = $(BOOST_PYTHON_V2_PROPERTIES) ;

#
rule bpl-test ( name ? : files * )
{
    files ?= $(name).py $(name).cpp ;
    
    local modules ;
    local py ;
    for local f in $(files)
    {
        if $(f:S) = .py
        {
            if $(py)
            {
                EXIT too many python drivers specified: "$(py)" "$(f)" ;
            }
            py = $(f) ;
        }
    }
    
    name ?= $(py:S=) ;

    for local f in $(files)
    {
        if $(f:S) != .py
        {
            local m = $(f:S=) ;
            
            if $(m) = $(py:S=)
            {
                m = $(name) ;
                
                if $(m) = $(py:S=)
                {
                    m = $(m)_ext ;
                }
            }
            extension $(m) : $(f) <dll>../bpl ;
            modules += $(m) ;
        }
    }
    
    boost-python-runtest $(name) : $(py) <pyd>$(modules) ;
}

bpl-test try : newtest.py m1.cpp m2.cpp ;
bpl-test builtin_converters : test_builtin_converters.py test_builtin_converters.cpp ;
bpl-test test_pointer_adoption ;
bpl-test callbacks ;
bpl-test virtual_functions ;
bpl-test back_reference ;
bpl-test implicit ;
bpl-test data_members ;

bpl-test bienstman1 ;
bpl-test bienstman2 ;
bpl-test bienstman3 ;
bpl-test multi_arg_constructor ;
if $(TEST_BIENSTMAN_NON_BUGS)
{
    bpl-test bienstman4 ;
    bpl-test bienstman5 ;
}

# --- unit tests of library components ---
unit-test indirect_traits_test
  : indirect_traits_test.cpp : <include>$(BOOST_ROOT) ;
unit-test destroy_test
  : destroy_test.cpp : <include>$(BOOST_ROOT)  ;
unit-test pointer_type_id_test
  : pointer_type_id_test.cpp : <include>$(BOOST_ROOT) ;

unit-test member_function_cast
  : member_function_cast.cpp : <include>$(BOOST_ROOT) ;

unit-test bases
  : bases.cpp : <include>$(BOOST_ROOT) ;

unit-test if_else
  : if_else.cpp : <include>$(BOOST_ROOT) ;

unit-test pointee
  : pointee.cpp : <include>$(BOOST_ROOT) ;

unit-test select_holder
  : select_holder.cpp
  : <include>$(BOOST_ROOT) <define>BOOST_PYTHON_STATIC_LIB $(PYTHON_PROPERTIES)
;

unit-test select_from_python_test
  : select_from_python_test.cpp 
    ../src/converter/type_id.cpp
    # ../src/converter/registry.cpp # MWerks needs this for some reason

  : <include>$(BOOST_ROOT) <define>BOOST_PYTHON_STATIC_LIB
    $(PYTHON_V1_PROPERTIES)
    ;


