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 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 testDelete(self): ops = ( ekeyword.Op("^", "arm", None), ekeyword.Op("^", "s390", None), ekeyword.Op("^", "x86", None), ) self._test("arm -s390 ~x86 bar", ops, "bar")
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 _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, 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': ('stable', '~arch'), 'arm': ('stable', 'arch'), 'm68k': ('exp', '~arch'), 's390': ('exp', 'arch'), } self._test('-* ~* * alpha arm m68k s390', ops, '-* ~* * ~alpha arm ~m68k s390', arch_status)
def testAllMultiUnstableStable(self): ops = ( ekeyword.Op("~", "all", None), ekeyword.Op(None, "all", None), ) arch_status = { "alpha": ("stable", "~arch"), "arm": ("stable", "arch"), "m68k": ("exp", "~arch"), "s390": ("exp", "arch"), } self._test( "-* ~* * alpha arm m68k s390", ops, "-* ~* * ~alpha arm ~m68k s390", arch_status, )
def testAllStable(self): ops = (ekeyword.Op(None, 'all', None), ) arch_status = { 'alpha': ('stable', '~arch'), 'arm': ('stable', 'arch'), 'm68k': ('exp', '~arch'), 's390': ('exp', 'arch'), } self._test('* ~alpha ~arm ~m68k ~mips ~s390 ~arm-linux', ops, '* ~alpha arm ~m68k ~mips s390 ~arm-linux', arch_status)
def testAllStable(self): ops = (ekeyword.Op(None, "all", None), ) arch_status = { "alpha": ("stable", "~arch"), "arm": ("stable", "arch"), "m68k": ("exp", "~arch"), "s390": ("exp", "arch"), } self._test( "* ~alpha ~arm ~m68k ~mips ~s390 ~arm-linux", ops, "* ~alpha arm ~m68k ~mips s390 ~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 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 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 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 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 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, '')
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 testAllNoStatus(self): ops = (ekeyword.Op(None, "all", None), ) self.assertRaises(ValueError, self._test, "", ops, "")