<s> from conary_test import rephelp <EOL> from conary . build import use <EOL> from conary . deps import arch , deps <EOL> from conary . deps . deps import parseFlavor <EOL> class TestUse ( rephelp . RepositoryHelper ) : <EOL> def testErrors ( self ) : <EOL> try : <EOL> bool ( use . Use . foo ) <EOL> except use . NoSuchUseFlagError : <EOL> pass <EOL> else : <EOL> raise RuntimeError <EOL> use . Use . _setStrictMode ( False ) <EOL> assert ( not bool ( use . Use . foo ) ) <EOL> def testUseExtras ( self ) : <EOL> Use = use . Use <EOL> Flags = use . LocalFlags <EOL> Arch = use . Arch <EOL> use . clearFlags ( ) <EOL> Arch . _setArchProps ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> Arch . _addFlag ( '<STR_LIT>' , archProps = { '<STR_LIT>' : True , '<STR_LIT>' : False , '<STR_LIT>' : True , '<STR_LIT>' : False } ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' , subsumes = [ '<STR_LIT>' ] ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' , subsumes = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' , subsumes = [ '<STR_LIT>' ] ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' ) <EOL> Arch . x86 . _addAlias ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> try : <EOL> Arch . x86 . _addAlias ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except RuntimeError , e : <EOL> assert ( str ( e ) == '<STR_LIT>' ) <EOL> else : <EOL> raise <EOL> try : <EOL> Arch . x86 . _addAlias ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except RuntimeError , e : <EOL> assert ( str ( e ) == '<STR_LIT>' ) <EOL> else : <EOL> raise <EOL> Arch . _setArch ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> Use . _addFlag ( '<STR_LIT>' ) <EOL> Flags . smp = True <EOL> assert ( Flags . smp == True ) <EOL> assert ( repr ( Flags ) == '<STR_LIT>' ) <EOL> f = use . createFlavor ( '<STR_LIT>' , [ Arch . x86 , Arch . x86 . sse , Arch . x86 . sse2 , Use . builddocs , Flags . smp ] ) <EOL> assert ( f . freeze ( ) == '<STR_LIT>' ) <EOL> use . Use . _addFlag ( '<STR_LIT>' , required = False , value = True ) <EOL> assert ( use . Use . bootstrap . _toDependency ( ) . freeze ( ) == '<STR_LIT>' ) <EOL> def testArch ( self ) : <EOL> Arch = use . ArchCollection ( ) <EOL> Arch . _setArchProps ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> Arch . _addFlag ( '<STR_LIT>' , archProps = { '<STR_LIT>' : True , '<STR_LIT>' : False , '<STR_LIT>' : True , '<STR_LIT>' : False } ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' , subsumes = [ '<STR_LIT>' ] ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' , subsumes = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' , subsumes = [ '<STR_LIT>' ] ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' ) <EOL> Arch . x86 . _addFlag ( '<STR_LIT>' ) <EOL> Arch . x86 . _addAlias ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> Arch . _addFlag ( '<STR_LIT>' , archProps = { '<STR_LIT>' : False , '<STR_LIT>' : True , '<STR_LIT>' : False , '<STR_LIT>' : True } ) <EOL> Arch . ppc . _addFlag ( '<STR_LIT>' ) <EOL> Arch . _setArch ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> assert ( Arch . ppc and Arch . ppc . ppc64 and not Arch . LE and not Arch . bits32 ) <EOL> assert ( Arch . bits64 ) <EOL> Arch . _setArch ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> assert ( not Arch . ppc and not Arch . ppc . ppc64 and Arch . LE and Arch . bits32 ) <EOL> assert ( not Arch . bits64 ) <EOL> Arch . _trackUsed ( True ) <EOL> bool ( Arch . x86 ) <EOL> bool ( Arch . x86 . sse2 ) <EOL> bool ( Arch . x86 . i686 ) <EOL> bool ( Arch . getCurrentArch ( ) . i686 ) <EOL> bool ( Arch . x86 . threednow ) <EOL> bool ( Arch . ppc . ppc64 ) <EOL> bool ( Arch . BE ) <EOL> bool ( Arch . LE ) <EOL> Arch . _trackUsed ( False ) <EOL> assert ( str ( use . createFlavor ( None , Arch . _iterUsed ( ) ) ) == '<STR_LIT>' ) <EOL> Arch . _setArch ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> Arch . _resetUsed ( ) <EOL> Arch . _trackUsed ( True ) <EOL> bool ( Arch . x86 . i586 ) == True <EOL> f = use . createFlavor ( None , Arch . _iterUsed ( ) ) <EOL> assert ( str ( f ) == '<STR_LIT>' ) <EOL> f = str ( use . createFlavor ( None , Arch . x86 . _iterAll ( ) ) ) <EOL> assert ( f . find ( '<STR_LIT>' ) == - <NUM_LIT:1> ) <EOL> assert ( f . find ( '<STR_LIT>' ) != - <NUM_LIT:1> ) <EOL> Arch . _setArch ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> Arch . _resetUsed ( ) <EOL> Arch . _trackUsed ( True ) <EOL> assert ( Arch . x86 . i586 == True ) <EOL> assert ( Arch . x86 . threednow == True ) <EOL> assert ( Arch . x86 . sse == True ) <EOL> assert ( str ( Arch . ppc . ppc64 ) == '<STR_LIT>' ) <EOL> Arch . x86 . i586 . setRequired ( False ) <EOL> Arch . x86 . threednow . setRequired ( False ) <EOL> f = use . createFlavor ( None , Arch . _iterUsed ( ) ) <EOL> assert ( str ( f ) == '<STR_LIT>' ) <EOL> Arch . _setArch ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> Arch . _resetUsed ( ) <EOL> Arch . _trackUsed ( True ) <EOL> bool ( Arch . ppc ) <EOL> f = use . createFlavor ( None , Arch . _iterUsed ( ) ) <EOL> assert ( str ( f ) == '<STR_LIT>' ) <EOL> Arch . _setArch ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> Arch . _resetUsed ( ) <EOL> Arch . _trackUsed ( True ) <EOL> bool ( Arch . ppc . ppc64 ) <EOL> f = use . createFlavor ( None , Arch . _iterUsed ( ) ) <EOL> assert ( str ( f ) == '<STR_LIT>' ) <EOL> def testTrack ( self ) : <EOL> Use = use . UseCollection ( ) <EOL> Use . _addFlag ( '<STR_LIT:foo>' , value = True ) <EOL> Use . _addFlag ( '<STR_LIT:bar>' , value = False ) <EOL> Use . _addFlag ( '<STR_LIT>' , value = False ) <EOL> assert ( Use . _getUsed ( ) == [ ] ) <EOL> Use . _trackUsed ( True ) <EOL> assert ( bool ( Use . foo ) ) <EOL> assert ( str ( Use . _getUsed ( ) ) == '<STR_LIT>' ) <EOL> Use . _trackUsed ( False ) <EOL> bool ( Use . bar ) <EOL> assert ( str ( Use . _getUsed ( ) ) == '<STR_LIT>' ) <EOL> Use . _resetUsed ( ) <EOL> assert ( Use . _getUsed ( ) == [ ] ) <EOL> Use . foo . _set ( False ) <EOL> Use . _trackUsed ( True ) <EOL> assert ( not bool ( Use . foo ) ) <EOL> Use . _getUsed ( ) <EOL> assert ( str ( Use . _getUsed ( ) ) == '<STR_LIT>' ) <EOL> Use . _trackUsed ( False ) <EOL> use . setUsed ( [ Use . bar ] ) <EOL> Use . _getUsed ( ) <EOL> assert ( str ( Use . _getUsed ( ) ) == '<STR_LIT>' ) <EOL> Use . _resetUsed ( ) <EOL> Use . _trackUsed ( True ) <EOL> Use . bar . _set ( ) <EOL> assert ( bool ( Use . bar ) ) <EOL> Use . _getUsed ( ) <EOL> assert ( str ( Use . _getUsed ( ) ) == '<STR_LIT>' ) <EOL> Use . _resetUsed ( ) <EOL> Use . bar . _set ( ) <EOL> Use . foo . _set ( False ) <EOL> Use . _trackUsed ( True ) <EOL> assert ( Use . bar | Use . foo ) <EOL> assert ( set ( x . _name for x in Use . _iterUsed ( ) ) == set ( [ '<STR_LIT:bar>' , '<STR_LIT:foo>' ] ) ) <EOL> Use . _resetUsed ( ) <EOL> Use . _trackUsed ( True ) <EOL> assert ( not Use . foo & Use . bar ) <EOL> assert ( set ( x . _name for x in Use . _iterUsed ( ) ) == set ( [ '<STR_LIT:bar>' , '<STR_LIT:foo>' ] ) ) <EOL> Use . _resetUsed ( ) <EOL> Use . _trackUsed ( True ) <EOL> assert ( not ( Use . foo & Use . bar & Use . bam ) ) <EOL> sorted ( x . _name for x in Use . _iterUsed ( ) ) <EOL> assert ( set ( x . _name for x in Use . _iterUsed ( ) ) == set ( [ '<STR_LIT>' , '<STR_LIT:bar>' , '<STR_LIT:foo>' ] ) ) <EOL> Use . _resetUsed ( ) <EOL> Use . _trackUsed ( True ) <EOL> assert ( Use . foo | Use . bar | Use . bam ) <EOL> assert ( set ( x . _name for x in Use . _iterUsed ( ) ) == set ( [ '<STR_LIT>' , '<STR_LIT:bar>' , '<STR_LIT:foo>' ] ) ) <EOL> Use . _resetUsed ( ) <EOL> Use . _trackUsed ( True ) <EOL> assert ( not ( Use . foo == True ) ) <EOL> assert ( [ x . _name for x in Use . _iterUsed ( ) ] == [ '<STR_LIT:foo>' ] ) <EOL> Use . _resetUsed ( ) <EOL> Use . _trackUsed ( True ) <EOL> assert ( True != Use . foo ) <EOL> assert ( [ x . _name for x in Use . _iterUsed ( ) ] == [ '<STR_LIT:foo>' ] ) <EOL> Arch = use . Arch <EOL> use . resetUsed ( ) <EOL> use . track ( True ) <EOL> assert ( not bool ( Arch . ppc . ppc64 ) ) <EOL> use . track ( False ) <EOL> assert ( use . getUsed ( ) == [ Arch . getCurrentArch ( ) ] ) <EOL> def testSetBuildFlagsFromFlavor ( self ) : <EOL> Flavor = deps . parseFlavor <EOL> use . setBuildFlagsFromFlavor ( None , Flavor ( '<STR_LIT>' ) ) <EOL> assert ( use . Arch . ppc ) <EOL> self . assertRaises ( RuntimeError , use . setBuildFlagsFromFlavor , <EOL> None , Flavor ( '<STR_LIT>' ) ) <EOL> use . setBuildFlagsFromFlavor ( None , Flavor ( '<STR_LIT>' ) ) <EOL> assert ( use . Arch . x86 ) <EOL> assert ( not use . Arch . ppc ) <EOL> self . assertRaises ( RuntimeError , use . setBuildFlagsFromFlavor , None , Flavor ( '<STR_LIT>' ) ) <EOL> self . assertRaises ( AttributeError , use . setBuildFlagsFromFlavor , <EOL> None , '<STR_LIT>' ) <EOL> self . logFilter . add ( ) <EOL> use . setBuildFlagsFromFlavor ( None , Flavor ( '<STR_LIT>' ) , error = False , <EOL> warn = True ) <EOL> self . logFilter . compare ( '<STR_LIT>' ) <EOL> assert ( not use . Use . ssl ) <EOL> use . setBuildFlagsFromFlavor ( None , Flavor ( '<STR_LIT>' ) , error = False ) <EOL> def testUseFlagPaths ( self ) : <EOL> Use = use . Use <EOL> for name , value in Use . iteritems ( ) : <EOL> self . assertTrue ( value . _path == '<STR_LIT>' % ( self . cfg . useDirs [ <NUM_LIT:0> ] , name ) ) <EOL> def testPackageFlags ( self ) : <EOL> assert ( not use . PackageFlags . kernel . pae ) <EOL> self . assertRaises ( RuntimeError , setattr , <EOL> use . PackageFlags . kernel , '<STR_LIT>' , True ) <EOL> self . assertRaises ( RuntimeError , setattr , <EOL> use . PackageFlags , '<STR_LIT:foo>' , True ) <EOL> self . assertRaises ( RuntimeError , bool , use . PackageFlags ) <EOL> assert ( not use . PackageFlags . kernel . pae ) <EOL> use . setBuildFlagsFromFlavor ( None , <EOL> parseFlavor ( '<STR_LIT>' ) , error = False ) <EOL> assert ( bool ( use . PackageFlags . kernel . pae ) ) <EOL> use . clearFlags ( ) <EOL> use . setBuildFlagsFromFlavor ( None , <EOL> parseFlavor ( '<STR_LIT>' ) , error = False ) <EOL> assert ( not bool ( use . PackageFlags . kernel . pae ) ) <EOL> assert ( str ( use . PackageFlags . kernel . pae ) == '<STR_LIT>' ) <EOL> def testTargetFlavor ( self ) : <EOL> use . setBuildFlagsFromFlavor ( None , self . cfg . buildFlavor , error = False ) <EOL> targetFlavor = str ( use . createFlavor ( None , use . Arch . _iterAll ( ) , targetDep = True ) ) <EOL> assert ( targetFlavor ) <EOL> flavor = str ( use . createFlavor ( None , use . Arch . _iterAll ( ) , targetDep = False ) ) <EOL> assert ( targetFlavor . replace ( '<STR_LIT:target>' , '<STR_LIT>' ) == flavor ) <EOL> def testMultilib ( self ) : <EOL> depSet = deps . DependencySet ( ) <EOL> depSet . addDeps ( deps . InstructionSetDependency , arch . flags_x86_64 ( ) [ <NUM_LIT:0> ] ) <EOL> use . setBuildFlagsFromFlavor ( None , depSet ) <EOL> self . assertTrue ( use . Arch . x86_64 ) <EOL> self . assertFalse ( use . Arch . x86 ) </s>
