On Wednesday 01 October 2008 18:24:56 Michael Andres wrote:
- added tests/include/TestSetup.h to ease building a test environment below some tempdir. Currently supports easy setup of Target, RepoManager and loading data (raw metadata and .solv files) into the pool.
That's how it currently looks like:
#include "TestSetup.h"
BOOST_AUTO_TEST_CASE(WhatProvides) { TestSetup test( Arch_x86_64 ); // use x86_64 as system arch test.loadTarget(); // initialize and load target test.loadRepo( TESTS_SRC_DIR"/data/openSUSE-11.1" );
This is all you need to setup Target, RepoManager below some temp directory and load the raw metadata into the pool.
In case you want to setup the system below some fix directory, use:
TestSetup test( "/tmp/mydir", Arch_x86_64 );
I just want to point out that the lifetime of the TestSetup instance is also the lifetime of the temp. directory! So if you want to setup a common environment for many test cases, you CAN'T DO IT LIKE THIS: BOOST_AUTO_TEST_CASE(init) { TestSetup test( Arch_x86_64 ); //test.loadTarget(); // initialize and load target test.loadRepo( TESTS_SRC_DIR "/data/openSUSE-11.1", "opensuse" ); test.loadRepo( TESTS_SRC_DIR "/data/OBS_zypp_svn-11.1", "zyppsvn" ); test.loadRepo( TESTS_SRC_DIR "/data/OBS:VirtualBox-11.1", "vbox" ); dumpRange( USR, test.pool().knownRepositoriesBegin(), test.pool().knownRepositoriesEnd() ); USR << "pool: " << test.pool() << endl; } Leaving the init function the directory gets deleted, which may result in strange effects. Best might be to have a global static instance, so you can also access all components and convenience methods we may add. static TestSetup test( Arch_x86_64 ); BOOST_AUTO_TEST_CASE(init) { //test.loadTarget(); // initialize and load target test.loadRepo( TESTS_SRC_DIR "/data/openSUSE-11.1", "opensuse" ); test.loadRepo( TESTS_SRC_DIR "/data/OBS_zypp_svn-11.1", "zyppsvn" ); test.loadRepo( TESTS_SRC_DIR "/data/OBS:VirtualBox-11.1", "vbox" ); dumpRange( USR, test.pool().knownRepositoriesBegin(), test.pool().knownRepositoriesEnd() ); USR << "pool: " << test.pool() << endl; } -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+