[LNT] r176905 - Created a static method on lnt.server.config.Config for generating a dummy
Michael Gottesman
mgottesman at apple.com
Tue Mar 12 15:14:40 PDT 2013
Author: mgottesman
Date: Tue Mar 12 17:14:40 2013
New Revision: 176905
URL: http://llvm.org/viewvc/llvm-project?rev=176905&view=rev
Log:
Created a static method on lnt.server.config.Config for generating a dummy
config and changed all usages in LNT of instantiation of a v4db to pass in a
config object to v4db (which is either a full blown config or a dummy config).
Modified:
lnt/trunk/lnt/lnttool/main.py
lnt/trunk/lnt/server/config.py
lnt/trunk/tests/server/db/CreateV4TestSuite.py
lnt/trunk/tests/server/db/CreateV4TestSuiteInstance.py
lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py
Modified: lnt/trunk/lnt/lnttool/main.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/main.py?rev=176905&r1=176904&r2=176905&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/main.py (original)
+++ lnt/trunk/lnt/lnttool/main.py Tue Mar 12 17:14:40 2013
@@ -108,8 +108,11 @@ def action_checkformat(name, args):
if input == '-':
input = StringIO.StringIO(sys.stdin.read())
-
- db = lnt.server.db.v4db.V4DB('sqlite:///:memory:')
+
+ import lnt.server.db.v4db
+ import lnt.server.config
+ db = lnt.server.db.v4db.V4DB('sqlite:///:memory:',
+ lnt.server.config.Config.dummyInstance())
result = lnt.util.ImportData.import_and_report(
None, None, db, input, 'json', commit = True)
lnt.util.ImportData.print_report_result(result, sys.stdout, sys.stderr,
@@ -180,7 +183,11 @@ def action_runtest(name, args):
# Construct a temporary database and import the result.
test_instance.log("submitting result to dummy instance")
- db = lnt.server.db.v4db.V4DB("sqlite:///:memory:")
+
+ import lnt.server.db.v4db
+ import lnt.server.config
+ db = lnt.server.db.v4db.V4DB("sqlite:///:memory:",
+ lnt.server.config.Config.dummyInstance())
result = lnt.util.ImportData.import_and_report(
None, None, db, tmp.name, 'json', commit = True)
lnt.util.ImportData.print_report_result(result, sys.stdout, sys.stderr,
Modified: lnt/trunk/lnt/server/config.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/config.py?rev=176905&r1=176904&r2=176905&view=diff
==============================================================================
--- lnt/trunk/lnt/server/config.py (original)
+++ lnt/trunk/lnt/server/config.py Tue Mar 12 17:14:40 2013
@@ -4,6 +4,7 @@ LNT Config object for tracking user-conf
import os
import re
+import tempfile
import lnt.server.db.v4db
@@ -60,7 +61,12 @@ class DBInfo:
str(dict.get('db_version', '0.4')),
dict.get('shadow_import', None),
email_config)
-
+
+ @staticmethod
+ def dummyInstance():
+ return DBInfo("sqlite:///:memory:", "0.4", None,
+ EmailConfig(False, '', '', []))
+
def __init__(self, path,
db_version, shadow_import, email_config):
self.config = None
@@ -97,7 +103,20 @@ class Config:
default_email_config))
for k,v in data['databases'].items()]),
data.get('baselineRevision', '144168'))
-
+
+ @staticmethod
+ def dummyInstance():
+ baseDir = tempfile.mkdtemp()
+ dbDir = '.'
+ dbDirPath = os.path.join(baseDir, dbDir)
+ tempDir = os.path.join(baseDir, 'tmp')
+ secretKey = None
+ dbInfo = {'dummy': DBInfo.dummyInstance()}
+ baselineRevision = '144168'
+
+ return Config('LNT', 'http://localhost:8000', dbDir, tempDir, secretKey, dbInfo,
+ baselineRevision)
+
def __init__(self, name, zorgURL, dbDir, tempDir, secretKey, databases,
baselineRevision):
self.name = name
Modified: lnt/trunk/tests/server/db/CreateV4TestSuite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/CreateV4TestSuite.py?rev=176905&r1=176904&r2=176905&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/CreateV4TestSuite.py (original)
+++ lnt/trunk/tests/server/db/CreateV4TestSuite.py Tue Mar 12 17:14:40 2013
@@ -6,11 +6,12 @@
# RUN: python %s %t.db
import sys
+from lnt.server.config import Config
from lnt.server.db import testsuite
from lnt.server.db import v4db
# Create an in memory database.
-db = v4db.V4DB("sqlite:///:memory:", echo=True)
+db = v4db.V4DB("sqlite:///:memory:", Config.dummyInstance(), echo=True)
# We expect exactly two test suites, one for NTS and one for Compile.
test_suites = list(db.query(testsuite.TestSuite))
Modified: lnt/trunk/tests/server/db/CreateV4TestSuiteInstance.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/CreateV4TestSuiteInstance.py?rev=176905&r1=176904&r2=176905&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/CreateV4TestSuiteInstance.py (original)
+++ lnt/trunk/tests/server/db/CreateV4TestSuiteInstance.py Tue Mar 12 17:14:40 2013
@@ -5,11 +5,12 @@
import datetime
+from lnt.server.config import Config
from lnt.server.db import testsuite
from lnt.server.db import v4db
# Create an in memory database.
-db = v4db.V4DB("sqlite:///:memory:", echo=True)
+db = v4db.V4DB("sqlite:///:memory:", Config.dummyInstance(), echo=True)
# Get the test suite wrapper.
ts_db = db.testsuite['nts']
Modified: lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py?rev=176905&r1=176904&r2=176905&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py (original)
+++ lnt/trunk/tests/server/db/ImportV4TestSuiteInstance.py Tue Mar 12 17:14:40 2013
@@ -38,11 +38,12 @@
import datetime, sys
import lnt.testing
+from lnt.server.config import Config
from lnt.server.db import testsuite
from lnt.server.db import v4db
# Load the test database.
-db = v4db.V4DB("sqlite:///%s" % sys.argv[1], echo=True)
+db = v4db.V4DB("sqlite:///%s" % sys.argv[1], Config.dummyInstance(), echo=True)
# Get the status kinds, and validate the IDs align with the testing IDs.
pass_kind = db.query(db.StatusKind).filter_by(id = lnt.testing.PASS).one()
More information about the llvm-commits
mailing list