def testDelete(self): ops = ( ekeyword.Op('^', 'arm', None), ekeyword.Op('^', 's390', None), ekeyword.Op('^', 'x86', None), ) self._test('arm -s390 ~x86 bar', ops, 'bar')
def testModify(self): ops = ( ekeyword.Op(None, 'arm', None), ekeyword.Op('~', 's390', None), ekeyword.Op('-', 'sh', None), ) self._test('~arm s390 ~sh moo', ops, 'arm ~s390 -sh moo')
def testAdd(self): ops = ( ekeyword.Op(None, 'arm', None), ekeyword.Op('~', 's390', None), ekeyword.Op('-', 'sh', None), ) self._test('moo', ops, 'arm ~s390 -sh moo')
def _testKeywords(self, line): ops = ( ekeyword.Op(None, 'arm', None), ekeyword.Op('~', 'sparc', None), ) return ekeyword.process_content( 'file', ['%s\n' % line], ops, quiet=True)
def _testSmoke(self, style='color-inline', verbose=0, quiet=0): ops = ( ekeyword.Op(None, 'arm', None), ekeyword.Op('~', 'sparc', None), ) ekeyword.process_content( 'asdf', ['KEYWORDS="arm"'], ops, verbose=verbose, quiet=quiet, style=style)
def _testSmoke(self, dry_run): ops = ( ekeyword.Op(None, 'arm', None), ekeyword.Op('~', 'sparc', None), ) orig_content, new_content = self._process_ebuild(ops, dry_run=dry_run) if dry_run: self.assertEqual(orig_content, new_content) else: self.assertNotEqual(orig_content, new_content)
def testAllMultiUnstableStable(self): ops = ( ekeyword.Op('~', 'all', None), ekeyword.Op(None, 'all', None), ) arch_status = { 'alpha': None, 'arm': 'stable', 'arm64': 'exp', 'm68k': 'dev', } self._test('-* ~* * alpha arm arm64 m68k', ops, '-* ~* * ~alpha arm ~arm64 ~m68k', arch_status)
def testAllDisabled(self): """Make sure ~all does not change -arch to ~arch""" ops = ( ekeyword.Op('~', 'all', None), ) self._test('alpha -sparc ~x86', ops, '~alpha -sparc ~x86', {})
def testAllStable(self): ops = (ekeyword.Op(None, 'all', None), ) arch_status = { 'alpha': None, 'arm': 'stable', 'arm64': 'exp', 'm68k': 'dev', } self._test('* ~alpha ~arm ~arm64 ~m68k ~mips ~arm-linux', ops, '* ~alpha arm ~arm64 ~m68k ~mips ~arm-linux', arch_status)
def testAllUnstable(self): ops = (ekeyword.Op('~', 'all', None), ) arch_status = { 'alpha': None, 'arm': 'stable', 'arm64': 'exp', 'm68k': 'dev', 's390': 'dev', 'sh': 'dev', } self._test('-* ~* * alpha arm arm64 m68k arm-linux', ops, '-* ~* * ~alpha ~arm ~arm64 ~m68k ~arm-linux', arch_status)
def testSync(self): ops = ( ekeyword.Op('=', 'arm64', 'arm'), ekeyword.Op('=', 'ppc64', 'ppc'), ekeyword.Op('=', 'amd64', 'x86'), ekeyword.Op('=', 'm68k', 'mips'), ekeyword.Op('=', 'ia64', 'alpha'), ekeyword.Op('=', 'sh', 'sparc'), ekeyword.Op('=', 's390', 's390x'), ekeyword.Op('=', 'boo', 'moo'), ) self._test( 'arm64 arm ' '~ppc64 ~ppc ' '~amd64 x86 ' 'm68k ~mips ' '-ia64 alpha ' 'sh -sparc ' 's390 ' 'moo ', ops, 'arm64 arm ~ppc64 ~ppc amd64 x86 ~m68k ~mips ia64 alpha ' '-sh -sparc boo moo')
def _test(self, arg, op): self.assertEqual(ekeyword.arg_to_op(arg), ekeyword.Op(*op))
def testManifestNotUpdated(self): """Verify we don't run `ebuild ... manifest` on unmodified files""" with mock.patch.object(subprocess, 'check_call') as m: self._process_ebuild((ekeyword.Op(None, 'arm', None), ), manifest=True) self.assertEqual(m.call_count, 0)
def testManifestUpdated(self): """Verify `ebuild ... manifest` runs on updated files""" with mock.patch.object(subprocess, 'check_call') as m: self._process_ebuild((ekeyword.Op('~', 'arm', None), ), manifest=True) m.assert_called_once_with(['ebuild', mock.ANY, 'manifest'])
def testAllNoStatus(self): ops = (ekeyword.Op(None, 'all', None), ) self.assertRaises(ValueError, self._test, '', ops, '')