From: "Magnus Granberg" <zorry@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/tinderbox-cluster:master commit in: pym/tbc/
Date: Wed,  2 Mar 2016 20:50:27 +0000 (UTC)	[thread overview]
Message-ID: <1456951859.e57dd6203e4c04ac18c4b5333bf6c78b1a1eff11.zorry@gentoo> (raw)
commit:     e57dd6203e4c04ac18c4b5333bf6c78b1a1eff11
Author:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
AuthorDate: Wed Mar  2 20:50:59 2016 +0000
Commit:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
CommitDate: Wed Mar  2 20:50:59 2016 +0000
URL:        https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=e57dd620
add more support for use test
 pym/tbc/build_job.py  | 49 ++++++++++++++++++++++++++++++++++++-------------
 pym/tbc/db_mapping.py |  6 ++++--
 pym/tbc/flags.py      | 10 ++--------
 pym/tbc/package.py    | 18 +++++++++++++-----
 pym/tbc/sqlquerys.py  | 15 ++++++---------
 5 files changed, 61 insertions(+), 37 deletions(-)
diff --git a/pym/tbc/build_job.py b/pym/tbc/build_job.py
index dcec3b9..e8ab829 100644
--- a/pym/tbc/build_job.py
+++ b/pym/tbc/build_job.py
@@ -67,6 +67,14 @@ class build_job_action(object):
 		build_cpv_list = []
 		depclean_fail = True
 		disable_test_features = False
+		enable_test_features = False
+		restrictions_test = False
+		restrictions_list= get_ebuild_restrictions(self._session, build_dict['ebuild_id'])
+		if restrictions_list:
+			if "test" in restrictions_list:
+				restrictions_test = True
+		if restrictions_test and "test" in settings.features:
+			disable_test_features = True
 		for k, build_use_flags_list in buildqueru_cpv_dict.items():
 			build_cpv_list.append("=" + k)
 			if not build_use_flags_list == None:
@@ -80,22 +88,37 @@ class build_job_action(object):
 					f.write(filetext)
 					f.write('\n')
 					f.close
-		if not build_dict['build_useflags'] is None:
-			if "test" in build_dict['build_useflags'] and "test" in settings.features:
-				if build_dict['build_useflags']['test'] is False:
-					disable_test_features = True
-		restrictions_dict = get_ebuild_restrictions(self._session, build_dict['ebuild_id'])
-		if restrictions_dict:
-			if "test" in restrictions_dict:
-				disable_test_features = True
-		if disable_test_features:
-			filetext = k + ' ' + 'notest.conf'
+
+			if not build_dict['build_useflags'] is None:
+				if "test" in build_dict['build_useflags']:
+					if build_dict['build_useflags']['test'] is False and "test" in settings.features:
+						disable_test_features = True
+					if build_dict['build_useflags']['test'] is True and not disable_test_features and "test" not in settings.features:
+						enable_test_features = True
+			if disable_test_features:
+				filetext = '=' + k + ' ' + 'notest.conf'
+				log_msg = "filetext: %s" % filetext
+				add_logs(self._session, log_msg, "info", self._config_id)
+				with open("/etc/portage/package.env/99_env", "a") as f:
+					f.write(filetext)
+					f.write('\n')
+					f.close
+		if enable_test_features:
+			filetext = k + ' ' + 'test.conf'
 			log_msg = "filetext: %s" % filetext
 			add_logs(self._session, log_msg, "info", self._config_id)
-			with open("/etc/portage/package.env", "a") as f:
+			with open("/etc/portage/package.env/99_env", "a") as f:
 				f.write(filetext)
 				f.write('\n')
 				f.close
+			filetext = '=' + k + ' ' + 'test.conf'
+			log_msg = "filetext: %s" % filetext
+			add_logs(self._session, log_msg, "info", self._config_id)
+			with open("/etc/portage/package.env/99_env", "a") as f:
+				f.write(filetext)
+				f.write('\n')
+				f.close
+
 		log_msg = "build_cpv_list: %s" % (build_cpv_list,)
 		add_logs(self._session, log_msg, "info", self._config_id)
 
@@ -138,8 +161,8 @@ class build_job_action(object):
 			os.remove("/etc/portage/package.use/99_autounmask")
 			with open("/etc/portage/package.use/99_autounmask", "a") as f:
 				f.close
-			os.remove("/etc/portage/package.env")
-			with open("/etc/portage/package.env", "a") as f:
+			os.remove("/etc/portage/package.env/99_env")
+			with open("/etc/portage/package.env/99_env/", "a") as f:
 				f.close
 		except:
 			pass
diff --git a/pym/tbc/db_mapping.py b/pym/tbc/db_mapping.py
index 86884bf..34ac324 100644
--- a/pym/tbc/db_mapping.py
+++ b/pym/tbc/db_mapping.py
@@ -12,11 +12,13 @@ class Keywords(Base):
 	KeywordId = Column('keyword_id', Integer, primary_key=True)
 	Keyword = Column('keyword', String)
 	__tablename__ = 'keywords'
-	
+
 class Setups(Base):
 	SetupId = Column('setup_id', Integer, primary_key=True)
 	Setup = Column('setup', String(100))
 	Profile = Column('profile', String(150))
+	Test = Column('test', Boolean, default=False)
+	Repoman = Column('repoman', Boolean, default=False)
 	__tablename__ = 'setups'
 
 class Configs(Base):
@@ -25,7 +27,7 @@ class Configs(Base):
 	SetupId = Column('setup_id', Integer, ForeignKey('setups.setup_id'))
 	Host = Column('default_config', Boolean, default=False)
 	__tablename__ = 'configs'
-	
+
 class Logs(Base):
 	LogId = Column('log_id', Integer, primary_key=True)
 	ConfigId = Column('config_id', Integer, ForeignKey('configs.config_id'))
diff --git a/pym/tbc/flags.py b/pym/tbc/flags.py
index 82b7d42..10c9390 100644
--- a/pym/tbc/flags.py
+++ b/pym/tbc/flags.py
@@ -1,14 +1,8 @@
-#!/usr/bin/python
-#
-# Copyright 1998-2015 Gentoo Foundation
+# Copyright 1998-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # Origin flags.py from portage public api repo
 from __future__ import print_function
-from _emerge.main import parse_opts
-from _emerge.depgraph import backtrack_depgraph, depgraph, resume_depgraph
-from _emerge.create_depgraph_params import create_depgraph_params
-from _emerge.actions import load_emerge_config
 import portage
 import os
 
@@ -163,7 +157,7 @@ class tbc_use_flags(object):
 		iuse_flags = self.filter_flags(self.get_iuse(), use_expand_hidden, usemasked, useforced)
 		#flags = filter_flags(use_flags, use_expand_hidden, usemasked, useforced)
 		final_flags = self.filter_flags(final_use, use_expand_hidden, usemasked, useforced)
-		return iuse_flags, final_flags
+		return iuse_flags, final_flags, usemasked
 
 	def get_flags_looked(self):
 		"""Retrieves all information needed to filter out hidden, masked, etc.
diff --git a/pym/tbc/package.py b/pym/tbc/package.py
index c069c7e..255ec67 100644
--- a/pym/tbc/package.py
+++ b/pym/tbc/package.py
@@ -56,16 +56,20 @@ class tbc_package(object):
 
 					# Get the iuse and use flags for that config/setup and cpv
 					init_useflags = tbc_use_flags(mysettings_setup, myportdb_setup, build_cpv)
-					iuse_flags_list, final_use_list = init_useflags.get_flags()
+					iuse_flags_list, final_use_list, usemasked = init_useflags.get_flags()
 					iuse_flags_list2 = []
 					for iuse_line in iuse_flags_list:
 						iuse_flags_list2.append( init_useflags.reduce_flag(iuse_line))
-
+					enable_test = False
+					if SetupInfo.Test:
+						if not "test" in usemasked:
+							enable_test = True
 					# Dict the needed info
 					attDict = {}
 					attDict['cpv'] = build_cpv
 					attDict['useflags'] = final_use_list
 					attDict['iuse'] = iuse_flags_list2
+					attDict['test'] = enable_test
 					config_cpv_dict[ConfigInfo.SetupId] = attDict
 
 				# Clean some cache
@@ -156,6 +160,7 @@ class tbc_package(object):
 					use_flagsDict[x] = True
 				for x in use_disable:
 					use_flagsDict[x] = False
+				enable_test = v['test']
 				# Unpack packageDict
 				i = 0
 				for k, v in packageDict.items():
@@ -163,9 +168,12 @@ class tbc_package(object):
 
 					# Comper and add the cpv to buildqueue
 					if build_cpv == k:
-						restrictions_dict = get_ebuild_restrictions(self._session, ebuild_id)
-						if restrictions_dict:
-							if "test" in restrictions_dict and "test" in use_flagsDict:
+						# check if we need to enable or disable test
+						if "test" in use_flagsDict and enable_test:
+							use_flagsDict['test'] = True
+						restrictions_list = get_ebuild_restrictions(self._session, ebuild_id)
+						if restrictions_list:
+							if "test" in restrictions_list and "test" in use_flagsDict:
 								use_flagsDict['test'] = False
 						add_new_build_job(self._session, ebuild_id, setup_id, use_flagsDict, self._config_id)
 						# B = Build cpv use-flags config
diff --git a/pym/tbc/sqlquerys.py b/pym/tbc/sqlquerys.py
index 85621fe..60f4ba8 100644
--- a/pym/tbc/sqlquerys.py
+++ b/pym/tbc/sqlquerys.py
@@ -561,16 +561,13 @@ def get_ebuild_id_db(session, checksum, package_id, ebuild_version):
 
 def get_ebuild_restrictions(session, ebuild_id):
 	restrictions = []
-	try:
-		EbuildsRestrictionsInfo = session.query(EbuildsRestrictions).filter_by(EbuildId = ebuild_id).one()
-	except NoResultFound as e:
+	EbuildsRestrictionsInfos = session.query(EbuildsRestrictions).filter_by(EbuildId = ebuild_id).all()
+	if EbuildsRestrictionsInfos == []:
 		return False
-	except MultipleResultsFound as e:
-		EbuildsRestrictionsInfos = session.query(EbuildsRestrictions).filter_by(EbuildId = ebuild_id).all()
-		for EbuildsRestrictionsInfo in EbuildsRestrictionsInfos:
-			restrictions.append(session.query(Restrictions).filter_by(RestrictionId = EbuildsRestrictionsInfo.RestrictionId).one())
-		return restrictions
-	return restrictions.append(session.query(Restrictions).filter_by(RestrictionId = EbuildsRestrictionsInfo.RestrictionId).one())
+	for EbuildsRestrictionsInfo in EbuildsRestrictionsInfos:
+		RestrictionsInfo = session.query(Restrictions).filter_by(RestrictionId = EbuildsRestrictionsInfo.RestrictionId).one()
+		restrictions.append(RestrictionsInfo.Restriction)
+	return restrictions
 
 def add_repoman_log(session, package_id, repoman_log, repoman_hash):
 	try:
next             reply	other threads:[~2016-03-02 20:50 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02 20:50 Magnus Granberg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-02-05  2:52 [gentoo-commits] proj/tinderbox-cluster:master commit in: pym/tbc/ Magnus Granberg
2017-01-15 19:57 Magnus Granberg
2017-01-08 15:33 Magnus Granberg
2017-01-08 15:33 Magnus Granberg
2016-12-22 18:31 Magnus Granberg
2016-12-22 11:29 Magnus Granberg
2016-12-22 11:29 Magnus Granberg
2016-12-22 11:29 Magnus Granberg
2016-12-22 10:15 Magnus Granberg
2016-12-22 10:11 Magnus Granberg
2016-12-22 10:11 Magnus Granberg
2016-12-20 22:13 Magnus Granberg
2016-12-20 21:21 Magnus Granberg
2016-12-20 21:16 Magnus Granberg
2016-12-20 20:25 Magnus Granberg
2016-12-20 20:25 Magnus Granberg
2016-12-20 20:25 Magnus Granberg
2016-12-10 16:17 Magnus Granberg
2016-12-05 21:11 Magnus Granberg
2016-11-20 15:37 Magnus Granberg
2016-11-15 21:58 Magnus Granberg
2016-03-06 17:47 Magnus Granberg
2016-03-03 15:26 Magnus Granberg
2016-02-29 23:01 Magnus Granberg
2016-02-22 18:33 Magnus Granberg
2016-02-22 18:11 Magnus Granberg
2016-02-22 17:08 Magnus Granberg
2016-02-20 12:12 Magnus Granberg
2016-02-10 20:24 Magnus Granberg
2016-02-02 23:13 Magnus Granberg
2016-01-31 13:39 Magnus Granberg
2016-01-27  5:21 Magnus Granberg
2016-01-26 23:16 Magnus Granberg
2016-01-26 20:29 Magnus Granberg
2016-01-25 22:48 Magnus Granberg
2016-01-18 20:26 Magnus Granberg
2016-01-10 12:53 Magnus Granberg
2016-01-07  7:33 Magnus Granberg
2015-12-21 22:54 Magnus Granberg
2015-12-20  0:12 Magnus Granberg
2015-10-06 19:31 Magnus Granberg
2015-09-06 20:29 Magnus Granberg
2015-09-03 21:03 Magnus Granberg
2015-08-05  1:10 Magnus Granberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=1456951859.e57dd6203e4c04ac18c4b5333bf6c78b1a1eff11.zorry@gentoo \
    --to=zorry@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox