def test_createTestStubsPathExists( ):
    testRootPath = common.createTestPath( 'testRoot' )
    common.setupPath( testRootPath )
    [ testModules, includeFiles ] = __setupTestFiles__( )
    for mod in testModules:
        os.makedirs( os.path.dirname( mod.testStubPath( testRootPath ) ) )

    mgr = filemgr.filemgr( [ __sourcePath1__, __sourcePath2__ ], [ __includePath1__, __includePath2__ ] )
    mgr.createTestStubs( testRootPath )

    for mod in testModules:
        assert os.path.exists( mod.testStubPath( testRootPath ) )
Exemple #2
0
def test_findFilesMultiplePaths( ):
    common.setupPath( common.createTestPath( 'folder1' ) )
    common.setupPath( common.createTestPath( 'folder2' ) )

    common.touchFile( common.createTestPath( 'testFile1.x' ) )
    common.touchFile( common.createTestPath( 'folder1/testFile2.x' ) )
    common.touchFile( common.createTestPath( 'folder2/testFile3.y' ) )
    
    fileList = misc.findFiles( common.rootPath, '.x' )
    assert 'testFile1.x' in fileList
    assert 'folder1/testFile2.x' in fileList
    assert not 'folder1/testFile3.y' in fileList
    assert not 'testFile3.y' in fileList
def test_createTestCMakeList( ):
    testRootPath = common.createTestPath( 'testRoot' )
    common.setupPath( testRootPath )
    [ testModules, includeFiles ] = __setupTestFiles__( )

    mgr = filemgr.filemgr( [ __sourcePath1__, __sourcePath2__ ], [ __includePath1__, __includePath2__ ] )
    mgr.createTestCMakeList( testRootPath )

    assert os.path.exists( os.path.join( testRootPath, 'CMakeLists.txt' ) )
    
    mgr.createTestCMakeList( testRootPath )

    assert os.path.exists( os.path.join( testRootPath, 'CMakeLists.txt' ) )
def test_constructorNoFiles( ):
    common.setupPath( __sourcePath1__ )
    common.setupPath( __sourcePath2__ )
    common.setupPath( __includePath1__ )
    common.setupPath( __includePath2__ )

    mgr = filemgr.filemgr( [ __sourcePath1__, __sourcePath2__ ], [ __includePath1__, __includePath2__ ] )
    assert not mgr.__modules__
    assert not mgr.__includeFiles__
Exemple #5
0
def test_generateTemplates(capsys):
    sourceFolder = common.createTestPath('source')
    templateFolder = os.path.join(sourceFolder, 'templates')
    destFolder = common.createTestPath('dest')
    common.setupPath(sourceFolder)
    common.setupPath(templateFolder)
    common.setupPath(destFolder)

    for file in templates.__templateFileList__:
        common.touchFile(os.path.join(templateFolder, file))

    templates.generateTemplates(sourceFolder, destFolder)
    captured = capsys.readouterr()

    output = ''
    for file in templates.__templateFileList__:
        output += 'Copying template file {} to {}\n'.format(
            os.path.join(templateFolder, file), os.path.join(destFolder, file))
        assert os.path.exists(os.path.join(destFolder, file))
    assert captured.out == output

    templates.generateTemplates(sourceFolder, destFolder)
    captured = capsys.readouterr()

    output = ''
    for file in templates.__templateFileList__:
        output += 'Template file {} already exists\n'.format(
            os.path.join(destFolder, file))
        assert os.path.exists(os.path.join(destFolder, file))
    assert captured.out == output
def test_constructorNoIncludePath( ):
    common.setupPath( __sourcePath1__ )
    common.setupPath( __sourcePath2__ )
    
    with pytest.raises( Exception ):
        assert filemgr.filemgr( [ __sourcePath1__, __sourcePath2__ ], [ __includePath1__, __includePath2__ ] )
def __setupTestFiles__( ):
    common.setupPath( __sourcePath1__ )
    common.setupPath( __sourcePath2__ )
    common.setupPath( os.path.join( __sourcePath1__, 'folder1' ) )
    common.setupPath( __includePath1__ )
    common.setupPath( __includePath2__ )
    common.setupPath( os.path.join( __includePath1__, 'folder2' ) )

    common.touchFile( os.path.join( __sourcePath1__, 'fileA.c' ) )
    common.touchFile( os.path.join( __sourcePath1__, 'fileB.c' ) )
    common.touchFile( os.path.join( __sourcePath1__, 'fileC.c' ) )
    common.touchFile( os.path.join( __sourcePath1__, 'fileF.c' ) )
    common.touchFile( os.path.join( __sourcePath2__, 'fileG.c' ) )
    common.touchFile( os.path.join( __sourcePath1__, 'folder1', 'fileE.c' ) )

    common.touchFile( os.path.join( __includePath1__, 'fileA.h' ) )
    common.touchFile( os.path.join( __includePath1__, 'fileB.h' ) )
    common.touchFile( os.path.join( __includePath1__, 'fileD.h' ) )
    common.touchFile( os.path.join( __includePath1__, 'fileE.h' ) )
    common.touchFile( os.path.join( __includePath2__, 'fileG.h' ) )
    common.touchFile( os.path.join( __includePath1__, 'folder2', 'fileF.h' ) )

    modules = [ ]
    modules.append( __createTestCModule__( os.path.join( __sourcePath1__, 'fileA.c' ), 'fileA', os.path.join( __includePath1__, 'fileA.h' ) ) )
    modules.append( __createTestCModule__( os.path.join( __sourcePath1__, 'fileB.c' ), 'fileB', os.path.join( __includePath1__, 'fileB.h' ) ) )
    modules.append( __createTestCModule__( os.path.join( __sourcePath1__, 'fileC.c' ), 'fileC', '' ) )
    modules.append( __createTestCModule__( os.path.join( __sourcePath1__, 'folder1/fileE.c' ), 'fileE', os.path.join( __includePath1__, 'fileE.h' ) ) )
    modules.append( __createTestCModule__( os.path.join( __sourcePath1__, 'fileF.c' ), 'fileF', os.path.join( __includePath1__, 'folder2/fileF.h' ) ) )
    modules.append( __createTestCModule__( os.path.join( __sourcePath2__, 'fileG.c' ), 'fileG', os.path.join( __includePath2__, 'fileG.h' ) ) )
    includeFiles = [ ]
    includeFiles.append( os.path.join( __includePath1__, 'fileA.h' ) )
    includeFiles.append( os.path.join( __includePath1__, 'fileB.h' ) )
    includeFiles.append( os.path.join( __includePath1__, 'fileD.h' ) )
    includeFiles.append( os.path.join( __includePath1__, 'fileE.h' ) )
    includeFiles.append( os.path.join( __includePath2__, 'fileG.h' ) )
    includeFiles.append( os.path.join( __includePath1__, 'folder2/fileF.h' ) )

    return [ modules, includeFiles ]