зеркало из https://github.com/mozilla/stoneridge.git
Add ability to test stoneridge without modifying source.
This lets us test the harness without running any actual tests. One fake test is run, and DNS will not actually be updated, when everything is run as necessary.
This commit is contained in:
Родитель
82230159fe
Коммит
b48cf4689f
16
srdns.py
16
srdns.py
|
@ -21,6 +21,8 @@ dnspat = re.compile('^[0-9]+ : ([0-9.]+)$')
|
|||
|
||||
rundir = tempfile.mkdtemp()
|
||||
|
||||
nochange = False
|
||||
|
||||
class BaseDnsModifier(SocketServer.BaseRequestHandler):
|
||||
"""A class providing an interface for modifying DNS servers on a platform.
|
||||
"""
|
||||
|
@ -87,7 +89,10 @@ class MacDnsModifier(BaseDnsModifier):
|
|||
orig_dns = f.read().strip()
|
||||
|
||||
if orig_dns is not None:
|
||||
self._set_dns(orig_dns)
|
||||
if nochange:
|
||||
print 'Reset to %s' % (orig_dns,)
|
||||
else:
|
||||
self._set_dns(orig_dns)
|
||||
|
||||
def set_dns(self, dnsserver):
|
||||
# Save the current primary dns server
|
||||
|
@ -104,7 +109,10 @@ class MacDnsModifier(BaseDnsModifier):
|
|||
f.write('%s\n' % (' '.join(orig_dns),))
|
||||
|
||||
# Now set the primary dns server to our new one
|
||||
self._set_dns(dnsserver)
|
||||
if nochange:
|
||||
print 'Set to %s' % (dnsserver,)
|
||||
else:
|
||||
self._set_dns(dnsserver)
|
||||
|
||||
class LinuxDnsModifier(BaseDnsModifier):
|
||||
def setup(self):
|
||||
|
@ -176,8 +184,12 @@ def main():
|
|||
parser.add_argument('--pidfile', dest='pidfile')
|
||||
parser.add_argument('--log', dest='log')
|
||||
parser.add_argument('--nodaemon', dest='nodaemon', action='store_true')
|
||||
parser.add_argument('--nochange', dest='nochange', action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
global nochange
|
||||
nochange = args.nochange
|
||||
|
||||
if args.nodaemon:
|
||||
if args.pidfile:
|
||||
do_mutex_exit(parser, '--pidfile')
|
||||
|
|
|
@ -35,8 +35,12 @@ class StoneRidgeRunner(object):
|
|||
if not self.tests:
|
||||
logging.debug('searching for all tests in %s' %
|
||||
(stoneridge.testroot,))
|
||||
tests = [os.path.basename(f) for f in
|
||||
glob.glob(os.path.join(stoneridge.testroot, '*.js'))]
|
||||
if stoneridge.get_config('test', 'enabled'):
|
||||
tests = ['fake.js']
|
||||
else:
|
||||
tests = [os.path.basename(f) for f in
|
||||
glob.glob(os.path.join(stoneridge.testroot, '*.js'))]
|
||||
tests.remove('fake.js')
|
||||
logging.debug('tests found %s' % (tests,))
|
||||
return tests
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
function run_test()
|
||||
{
|
||||
startTime = new Date();
|
||||
endTime = new Date(startTime.valueOf() + 100);
|
||||
do_write_result("junk", startTime, endTime);
|
||||
do_test_finish();
|
||||
}
|
Загрузка…
Ссылка в новой задаче