Import('use')

testEnv = use.Clone()
testEnv.VariantDir('test', '../../', duplicate = False)
testEnv.VariantDir('common', '../common/', duplicate = False)

more_source = []
def addObjects(files):
    more_source.extend(files)

use = testEnv
SConscript('../../mugen/parser/SConstruct', exports = ['use', 'addObjects'], variant_dir = 'test-parser')

most_game_source = Split("""
test/mugen/character.cpp
test/mugen/helper.cpp
test/mugen/evaluator.cpp
test/mugen/compiler.cpp
test/mugen/state-controller.cpp
test/mugen/stage.cpp
test/mugen/sprite.cpp
test/mugen/sound.cpp
test/mugen/exception.cpp
test/mugen/util.cpp
test/mugen/animation.cpp
test/mugen/item-content.cpp
test/mugen/item.cpp
test/mugen/command.cpp
test/mugen/background.cpp
test/mugen/parse-cache.cpp
test/util/gui/rectarea.cpp
test-parser/air.cpp
test-parser/def.cpp
test-parser/cmd.cpp
test/paintown-engine/object/object.cpp
test/paintown-engine/object/object_attack.cpp
test/util/sound.cpp
test/paintown-engine/script/script.cpp
test/util/load_exception.cpp
test/util/network/network.cpp
test/mugen/ast/ast.cpp
test/util/input/input-manager.cpp
test/util/input/input-source.cpp
test/util/input/keyboard.cpp
test/util/input/joystick.cpp
test/util/input/allegro/allegro-joystick.cpp
test/util/input/sdl/joystick.cpp
test/globals.cpp
test/util/debug.cpp
test/menu/font-info.cpp
test/configuration.cpp
test/util/events.cpp
test/util/thread.cpp
test/util/bitmap.cpp
test/util/timedifference.cpp
test/util/funcs.cpp
test/util/font.cpp
test/util/ftalleg.cpp
test/util/regex.cpp
test/util/system.cpp
test/util/audio.cpp
test/util/file-system.cpp
test/util/message-queue.cpp
test/util/token.cpp
test/util/tokenreader.cpp
test/util/token_exception.cpp
test/exceptions/exception.cpp
test/factory/font_render.cpp
test/factory/font_factory.cpp
test/util/windows/system.cpp
test/util/input/text-input.cpp
test/util/console.cpp
test/paintown-engine/game/world.cpp
test/mugen/config.cpp
test/mugen/characterhud.cpp
test/mugen/behavior.cpp
test/util/gui/fadetool.cpp
test/mugen/font.cpp
test/mugen/reader.cpp
test/mugen/section.cpp

""")

load_source = Split("""
load.cpp
common/init.cpp
""")

stage_source = Split("""
load-stage.cpp
common/init.cpp
test/util/gui/animation.cpp
test/util/gui/coordinate.cpp
test/mugen/stage.cpp
test/mugen/character.cpp
test/mugen/helper.cpp
test/mugen/evaluator.cpp
test/mugen/compiler.cpp
test/mugen/sprite.cpp
test/mugen/state-controller.cpp
test/mugen/font.cpp
test/mugen/sound.cpp
test/mugen/exception.cpp
test/mugen/util.cpp
test/mugen/animation.cpp
test/mugen/background.cpp
test/mugen/item-content.cpp
test/mugen/item.cpp
test/mugen/parse-cache.cpp
test/mugen/characterhud.cpp
test/util/gui/rectarea.cpp
test/menu/font-info.cpp
test/util/audio.cpp
test-parser/air.cpp
test-parser/def.cpp
test-parser/cmd.cpp
test/factory/collector.cpp
test/paintown-engine/factory/shadow.cpp
test/paintown-engine/factory/object_factory.cpp
test/paintown-engine/factory/heart_factory.cpp
test/util/resource.cpp
test/nameplacer.cpp
test/paintown-engine/game/mod.cpp
test/util/ebox.cpp
test/paintown-engine/level/utils.cpp
test/paintown-engine/level/blockobject.cpp
test/paintown-engine/game/select_player.cpp
test/util/loading.cpp
test/util/messages.cpp
test/util/gradient.cpp
test/openbor/mod.cpp
test/openbor/util.cpp
test/openbor/pack-reader.cpp
test/paintown-engine/object/item.cpp
test/paintown-engine/object/attack.cpp
test/paintown-engine/object/projectile.cpp
test/paintown-engine/object/animation_event.cpp
test/paintown-engine/object/animation_trail.cpp
test/paintown-engine/object/animation.cpp
test/paintown-engine/object/gib.cpp
test/paintown-engine/object/cat.cpp
test/paintown-engine/object/actor.cpp
test/paintown-engine/object/object_nonattack.cpp
test/paintown-engine/object/enemy.cpp
test/paintown-engine/object/draw-effect.cpp
test/paintown-engine/object/character.cpp
test/paintown-engine/object/display_character.cpp
test/paintown-engine/object/heart.cpp
test/paintown-engine/object/stimulation.cpp
test/paintown-engine/object/object.cpp
test/paintown-engine/object/object_attack.cpp
test/paintown-engine/object/network_player.cpp
test/paintown-engine/object/network_character.cpp
test/util/sound.cpp
test/mugen/ast/ast.cpp
test/paintown-engine/script/script.cpp
test/util/load_exception.cpp
test/util/network/network.cpp
test/util/input/input-manager.cpp
test/util/input/input-source.cpp
test/util/input/keyboard.cpp
test/util/input/joystick.cpp
test/util/input/allegro/allegro-joystick.cpp
test/util/input/sdl/joystick.cpp
test/globals.cpp
test/util/debug.cpp
test/configuration.cpp
test/util/bitmap.cpp
test/util/timedifference.cpp
test/util/funcs.cpp
test/util/font.cpp
test/util/ftalleg.cpp
test/util/regex.cpp
test/util/system.cpp
test/util/file-system.cpp
test/util/message-queue.cpp
test/util/token.cpp
test/util/tokenreader.cpp
test/util/token_exception.cpp
test/paintown-engine/game/world.cpp
test/util/console.cpp
test/util/input/text-input.cpp
test/exceptions/exception.cpp
test/util/thread.cpp
test/util/events.cpp
test/factory/font_render.cpp
test/factory/font_factory.cpp
test/util/windows/system.cpp
test/mugen/config.cpp
test/mugen/behavior.cpp
test/util/gui/fadetool.cpp
test/mugen/reader.cpp
test/mugen/command.cpp
test/mugen/section.cpp
""")

select_source = most_game_source + Split("""
load-select.cpp
common/init.cpp
test/paintown-engine/object/object_nonattack.cpp
test/mugen/character-select.cpp
test/mugen/search.cpp
test/util/music.cpp
test/util/music-player.cpp
test/util/messages.cpp
test/util/gradient.cpp
test/util/loading.cpp
test/util/resource.cpp
test/paintown-engine/level/utils.cpp
test/paintown-engine/object/heart.cpp
""")

ignore = """
test/util/ebox.cpp
test/nameplacer.cpp
test/paintown-engine/object/item.cpp
test/paintown-engine/object/attack.cpp
test/paintown-engine/object/cat.cpp
test/paintown-engine/object/projectile.cpp
test/paintown-engine/object/gib.cpp
test/paintown-engine/object/stimulation.cpp
test/paintown-engine/object/actor.cpp
test/paintown-engine/game/select_player.cpp
test/paintown-engine/object/network_player.cpp
test/paintown-engine/object/display_character.cpp
test/paintown-engine/object/draw-effect.cpp
test/paintown-engine/object/character.cpp
test/paintown-engine/object/network_character.cpp
test/paintown-engine/object/animation_event.cpp
test/paintown-engine/object/animation_trail.cpp
test/openbor/util.cpp
test/openbor/mod.cpp
test/openbor/pack-reader.cpp
test/paintown-engine/object/enemy.cpp
test/paintown-engine/object/animation.cpp
test/paintown-engine/game/mod.cpp
"""

full_source = most_game_source + Split("""
load-full.cpp
common/init.cpp
test/factory/collector.cpp
test/util/gui/animation.cpp
test/util/gui/coordinate.cpp
test/paintown-engine/level/blockobject.cpp
test/paintown-engine/factory/shadow.cpp
test/paintown-engine/factory/object_factory.cpp
test/paintown-engine/factory/heart_factory.cpp
test/paintown-engine/object/item.cpp
test/paintown-engine/object/attack.cpp
test/paintown-engine/object/projectile.cpp
test/paintown-engine/object/animation_event.cpp
test/paintown-engine/object/animation_trail.cpp
test/paintown-engine/object/animation.cpp
test/paintown-engine/object/gib.cpp
test/paintown-engine/object/cat.cpp
test/paintown-engine/object/actor.cpp
test/paintown-engine/object/object_nonattack.cpp
test/paintown-engine/object/enemy.cpp
test/util/messages.cpp
test/util/gradient.cpp
test/util/loading.cpp
test/paintown-engine/game/select_player.cpp
test/openbor/util.cpp
test/openbor/pack-reader.cpp
test/util/resource.cpp
test/openbor/mod.cpp
test/util/ebox.cpp
test/paintown-engine/level/utils.cpp
test/paintown-engine/object/draw-effect.cpp
test/paintown-engine/object/character.cpp
test/paintown-engine/object/display_character.cpp
test/paintown-engine/object/heart.cpp
test/paintown-engine/game/mod.cpp
test/paintown-engine/object/stimulation.cpp
test/paintown-engine/object/network_player.cpp
test/nameplacer.cpp
test/paintown-engine/object/network_character.cpp
""")

stage_source.append(testEnv.Peg('test/openbor/data.peg'))
full_source.append(testEnv.Peg('test/openbor/data.peg'))

ast_source = Split("""
test-parser/air.cpp
test-parser/def.cpp
test-parser/cmd.cpp
test/util/token.cpp
test/util/tokenreader.cpp
test/util/debug.cpp
test/util/system.cpp
test/util/token_exception.cpp
test/util/timedifference.cpp
test/mugen/exception.cpp
test/mugen/ast/ast.cpp
test/exceptions/exception.cpp
""")

sffv2_source = Split("""
sffv2.cpp
sff.cpp
test/util/debug.cpp
test/util/file-system.cpp
test/util/system.cpp
test/exceptions/exception.cpp
test/util/thread.cpp
test/util/funcs.cpp
test/util/bitmap.cpp
test/util/font.cpp
test/globals.cpp
test/factory/font_factory.cpp
test/util/ftalleg.cpp
test/util/message-queue.cpp
test/util/init.cpp
test/util/music.cpp
test/util/token.cpp
test/configuration.cpp
test/util/network/network.cpp
test/util/token_exception.cpp
test/util/input/keyboard.cpp
test/util/tokenreader.cpp
test/menu/font-info.cpp
test/util/load_exception.cpp
test/util/music-player.cpp
test/util/audio.cpp
test/util/sound.cpp
test/util/input/input-manager.cpp
test/util/input/input-source.cpp
test/util/events.cpp
test/util/input/joystick.cpp
test/util/input/sdl/joystick.cpp
""")

parse_source = Split("""
parse.cpp
test-parser/cmd.cpp
test-parser/def.cpp
test-parser/air.cpp
test/mugen/ast/ast.cpp
test/exceptions/exception.cpp
test/mugen/exception.cpp
test/util/token.cpp
test/util/tokenreader.cpp
test/util/token_exception.cpp
""")

match_source = Split("""
run-match.cpp
test/util/input/input-source.cpp
test/util/gui/animation.cpp
test/util/gui/coordinate.cpp
test/util/init.cpp
test/util/file-system.cpp
test/util/bitmap.cpp
test/util/network/network.cpp
test/util/system.cpp
test/util/debug.cpp
test/exceptions/exception.cpp
test/util/funcs.cpp
test/util/thread.cpp
test/util/font.cpp
test/factory/font_factory.cpp
test/util/message-queue.cpp
test/util/ftalleg.cpp
test/configuration.cpp
test/util/token.cpp
test/util/tokenreader.cpp
test/util/token_exception.cpp
test/util/load_exception.cpp
test/util/input/keyboard.cpp
test/util/sound.cpp
test/util/music.cpp
test/util/music-player.cpp
test/util/audio.cpp
test/globals.cpp
test/mugen/character.cpp
test/mugen/stage.cpp
test/mugen/behavior.cpp
test/mugen/compiler.cpp
test/mugen/command.cpp
test-parser/air.cpp
test-parser/def.cpp
test-parser/cmd.cpp
test/paintown-engine/object/object.cpp
test/paintown-engine/game/world.cpp
test/paintown-engine/object/object_attack.cpp
test/mugen/ast/ast.cpp
test/paintown-engine/script/script.cpp
test/mugen/exception.cpp
test/mugen/evaluator.cpp
test/mugen/helper.cpp
test/mugen/animation.cpp
test/mugen/sprite.cpp
test/mugen/util.cpp
test/mugen/config.cpp
test/util/timedifference.cpp
test/mugen/item-content.cpp
test/mugen/item.cpp
test/mugen/background.cpp
test/util/gui/rectarea.cpp
test/util/regex.cpp
test/mugen/sound.cpp
test/util/console.cpp
test/mugen/parse-cache.cpp
test/util/input/input-manager.cpp
test/util/events.cpp
test/util/input/joystick.cpp
test/util/input/text-input.cpp
test/util/input/sdl/joystick.cpp
test/util/input/allegro/allegro-joystick.cpp
test/mugen/font.cpp
test/mugen/characterhud.cpp
test/mugen/section.cpp
test/mugen/state-controller.cpp
test/factory/font_render.cpp
test/util/gui/fadetool.cpp
test/mugen/reader.cpp
""")

x = []
def makeTest(name, files):
    test = testEnv.Program(name, files)
    x.append(test)
    testEnv.AddPostAction(test, testEnv['PAINTOWN_TEST'])

# x.append(testEnv.Program('load', load_source + most_game_source))
makeTest('load-full', full_source)
makeTest('load-select', select_source)
makeTest('load', load_source + most_game_source)
makeTest('serialize', ['serialize.cpp'] + ast_source)
makeTest('load-stage', stage_source)
makeTest('sffv2', sffv2_source)
x.append(testEnv.Program('run-match', match_source))
x.append(testEnv.Program('parse', parse_source))
# x.append(testEnv.Program('load-stage', stage_source))
x.append(testEnv.Program('palette', ['palette.cpp', 'test/util/debug.cpp']))
Return('x')
