mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
Create a directory for python package, move 'testing' in there
Review URL: https://chromereviews.googleplex.com/3514028 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
100f10211e
commit
78d16cca6c
|
@ -2,13 +2,8 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import os
|
||||
import test
|
||||
|
||||
from os.path import join, exists
|
||||
|
||||
import testing
|
||||
from testing import test_configuration
|
||||
|
||||
def GetConfiguration(context, root):
|
||||
return testing.BrowserTestConfiguration(
|
||||
return test_configuration.BrowserTestConfiguration(
|
||||
context, root, fatal_static_type_errors=True)
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import testing
|
||||
from testing import test_configuration
|
||||
|
||||
def GetConfiguration(context, root):
|
||||
return ClientCompilationTestConfiguration(context, root)
|
||||
|
||||
|
||||
class ClientCompilationTestConfiguration(
|
||||
testing.CompilationTestConfiguration):
|
||||
test_configuration.CompilationTestConfiguration):
|
||||
def __init__(self, context, root):
|
||||
super(ClientCompilationTestConfiguration, self).__init__(context, root)
|
||||
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
|
||||
import os
|
||||
from os.path import join, exists
|
||||
import re
|
||||
|
||||
import test
|
||||
import utils
|
||||
|
||||
from os.path import join, exists
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import testing
|
||||
from testing import test_configuration
|
||||
|
||||
def GetConfiguration(context, root):
|
||||
return testing.StandardTestConfiguration(context, root)
|
||||
return test_configuration.StandardTestConfiguration(context, root)
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import os
|
||||
from os.path import join, exists
|
||||
import re
|
||||
|
||||
import test
|
||||
import utils
|
||||
|
||||
from os.path import join, exists
|
||||
|
||||
|
||||
class JUnitTestCase(test.TestCase):
|
||||
def __init__(self, path, context, classnames, mode, arch):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import testing
|
||||
from testing import test_configuration
|
||||
|
||||
def GetConfiguration(context, root):
|
||||
return testing.StandardTestConfiguration(context, root)
|
||||
return test_configuration.StandardTestConfiguration(context, root)
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import os
|
||||
import test
|
||||
|
||||
from os.path import join, exists
|
||||
|
||||
import test
|
||||
|
||||
class VmTestCase(test.TestCase):
|
||||
def __init__(self, path, context, mode, arch, flags):
|
||||
super(VmTestCase, self).__init__(context, path)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import testing
|
||||
from testing import test_configuration
|
||||
|
||||
def GetConfiguration(context, root):
|
||||
return testing.StandardTestConfiguration(context, root)
|
||||
return test_configuration.StandardTestConfiguration(context, root)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import testing
|
||||
from testing import test_configuration
|
||||
|
||||
def GetConfiguration(context, root):
|
||||
return testing.StandardTestConfiguration(context, root)
|
||||
return test_configuration.StandardTestConfiguration(context, root)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import testing
|
||||
from testing import test_configuration
|
||||
|
||||
def GetConfiguration(context, root):
|
||||
return testing.StandardTestConfiguration(context, root)
|
||||
return test_configuration.StandardTestConfiguration(context, root)
|
||||
|
|
|
@ -6,13 +6,14 @@ import os
|
|||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
import test
|
||||
import testing
|
||||
from testing import test_case,test_configuration
|
||||
import utils
|
||||
|
||||
from os.path import join, exists, isdir
|
||||
|
||||
class DartStubTestCase(testing.StandardTestCase):
|
||||
class DartStubTestCase(test_case.StandardTestCase):
|
||||
def __init__(self, context, path, filename, mode, arch):
|
||||
super(DartStubTestCase, self).__init__(context, path, filename, mode, arch)
|
||||
self.filename = filename
|
||||
|
@ -71,7 +72,7 @@ class DartStubTestCase(testing.StandardTestCase):
|
|||
return command
|
||||
|
||||
|
||||
class DartStubTestConfiguration(testing.StandardTestConfiguration):
|
||||
class DartStubTestConfiguration(test_configuration.StandardTestConfiguration):
|
||||
def __init__(self, context, root):
|
||||
super(DartStubTestConfiguration, self).__init__(context, root)
|
||||
|
||||
|
|
3
tools/testing/__init__.py
Normal file
3
tools/testing/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
143
tools/testing/test_case.py
Normal file
143
tools/testing/test_case.py
Normal file
|
@ -0,0 +1,143 @@
|
|||
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import atexit
|
||||
import fileinput
|
||||
import os
|
||||
import test
|
||||
import platform
|
||||
import re
|
||||
import run
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import test
|
||||
import utils
|
||||
|
||||
from os.path import join, exists, basename
|
||||
|
||||
import utils
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class StandardTestCase(test.TestCase):
|
||||
def __init__(self, context, path, filename, mode, arch):
|
||||
super(StandardTestCase, self).__init__(context, path)
|
||||
self.filename = filename
|
||||
self.mode = mode
|
||||
self.arch = arch
|
||||
self.run_arch = run.GetArchitecture(self.arch, self.mode, self.filename)
|
||||
for flag in context.flags:
|
||||
self.run_arch.vm_options.append(flag)
|
||||
|
||||
def IsNegative(self):
|
||||
return self.GetName().endswith("NegativeTest")
|
||||
|
||||
def GetLabel(self):
|
||||
return "%s%s %s" % (self.mode, self.arch, '/'.join(self.path))
|
||||
|
||||
def GetCommand(self):
|
||||
return self.run_arch.GetRunCommand();
|
||||
|
||||
def GetName(self):
|
||||
return self.path[-1]
|
||||
|
||||
def GetPath(self):
|
||||
return os.path.dirname(self.filename)
|
||||
|
||||
def GetSource(self):
|
||||
return file(self.filename).read()
|
||||
|
||||
|
||||
class MultiTestCase(StandardTestCase):
|
||||
|
||||
def __init__(self, context, path, filename, kind, mode, arch):
|
||||
super(MultiTestCase, self).__init__(context, path, filename, mode, arch)
|
||||
self.kind = kind
|
||||
|
||||
def GetCommand(self):
|
||||
return self.run_arch.GetRunCommand(
|
||||
fatal_static_type_errors=(self.kind == 'static type error'));
|
||||
|
||||
def IsNegative(self):
|
||||
if self.kind == 'compile-time error':
|
||||
return True
|
||||
if self.kind == 'runtime error':
|
||||
return False
|
||||
if self.kind == 'static type error':
|
||||
return self.run_arch.HasFatalTypeErrors()
|
||||
return False
|
||||
|
||||
class BrowserTestCase(StandardTestCase):
|
||||
def __init__(self, context, path, filename,
|
||||
fatal_static_type_errors, mode, arch):
|
||||
super(BrowserTestCase, self).__init__(context, path, filename, mode, arch)
|
||||
self.fatal_static_type_errors = fatal_static_type_errors
|
||||
|
||||
|
||||
def Run(self):
|
||||
command = self.run_arch.GetCompileCommand(self.fatal_static_type_errors)
|
||||
if command != None:
|
||||
# We change the directory where dartc will be launched because
|
||||
# it is not predictable on the location of the compiled file. In
|
||||
# case the test is a web test, we make sure the app file is not
|
||||
# in a subdirectory.
|
||||
cwd = None
|
||||
if self.run_arch.is_web_test: cwd = self.run_arch.temp_dir
|
||||
command = command[:1] + self.context.flags + command[1:]
|
||||
test_output = self.RunCommand(command, cwd=cwd)
|
||||
|
||||
# If errors were found, fail fast and show compile errors:
|
||||
if test_output.output.exit_code != 0:
|
||||
if not self.context.keep_temporary_files:
|
||||
self.run_arch.Cleanup()
|
||||
return test_output
|
||||
|
||||
command = self.run_arch.GetRunCommand();
|
||||
test_output = self.RunCommand(command)
|
||||
# The return value of DumpRenderedTree does not indicate test failing, but
|
||||
# the output does.
|
||||
if self.run_arch.HasFailed(test_output.output.stdout):
|
||||
test_output.output.exit_code = 1
|
||||
|
||||
# TODO(ngeoffray): We run out of space on the build bots for these tests if
|
||||
# the temp directories are not removed right after running the test.
|
||||
if not self.context.keep_temporary_files:
|
||||
self.run_arch.Cleanup()
|
||||
|
||||
return test_output
|
||||
|
||||
|
||||
class CompilationTestCase(test.TestCase):
|
||||
""" Run the dartc compiler on a given top level dart file """
|
||||
def __init__(self, path, context, filename, mode, arch):
|
||||
super(CompilationTestCase, self).__init__(context, path)
|
||||
self.filename = filename
|
||||
self.mode = mode
|
||||
self.arch = arch
|
||||
self.run_arch = run.GetArchitecture(self.arch, self.mode,
|
||||
self.filename)
|
||||
self.temp_dir = tempfile.mkdtemp(prefix='dartc-output-')
|
||||
|
||||
def IsNegative(self):
|
||||
return False
|
||||
|
||||
def GetLabel(self):
|
||||
return "%s/%s %s" % (self.mode, self.arch, '/'.join(self.path))
|
||||
|
||||
def GetCommand(self):
|
||||
cmd = self.context.GetDartC(self.mode, self.arch);
|
||||
cmd += self.context.flags
|
||||
cmd += ['-check-only',
|
||||
'-fatal-type-errors',
|
||||
'-Werror',
|
||||
'-out', self.temp_dir,
|
||||
self.filename]
|
||||
|
||||
return cmd
|
||||
|
||||
def GetName(self):
|
||||
return self.path[-1]
|
|
@ -12,12 +12,13 @@ import run
|
|||
import sys
|
||||
import tempfile
|
||||
|
||||
from testing import test_case
|
||||
import test
|
||||
import utils
|
||||
|
||||
from os.path import join, exists, basename
|
||||
|
||||
import utils # This is tools.utils
|
||||
import utils
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
@ -25,55 +26,6 @@ class Error(Exception):
|
|||
class TestConfigurationError(Error):
|
||||
pass
|
||||
|
||||
class StandardTestCase(test.TestCase):
|
||||
def __init__(self, context, path, filename, mode, arch):
|
||||
super(StandardTestCase, self).__init__(context, path)
|
||||
self.filename = filename
|
||||
self.mode = mode
|
||||
self.arch = arch
|
||||
self.run_arch = run.GetArchitecture(self.arch, self.mode, self.filename)
|
||||
for flag in context.flags:
|
||||
self.run_arch.vm_options.append(flag)
|
||||
|
||||
def IsNegative(self):
|
||||
return self.GetName().endswith("NegativeTest")
|
||||
|
||||
def GetLabel(self):
|
||||
return "%s%s %s" % (self.mode, self.arch, '/'.join(self.path))
|
||||
|
||||
def GetCommand(self):
|
||||
return self.run_arch.GetRunCommand();
|
||||
|
||||
def GetName(self):
|
||||
return self.path[-1]
|
||||
|
||||
def GetPath(self):
|
||||
return os.path.dirname(self.filename)
|
||||
|
||||
def GetSource(self):
|
||||
return file(self.filename).read()
|
||||
|
||||
|
||||
class MultiTestCase(StandardTestCase):
|
||||
|
||||
def __init__(self, context, path, filename, kind, mode, arch):
|
||||
super(MultiTestCase, self).__init__(context, path, filename, mode, arch)
|
||||
self.kind = kind
|
||||
|
||||
def GetCommand(self):
|
||||
return self.run_arch.GetRunCommand(
|
||||
fatal_static_type_errors=(self.kind == 'static type error'));
|
||||
|
||||
def IsNegative(self):
|
||||
if self.kind == 'compile-time error':
|
||||
return True
|
||||
if self.kind == 'runtime error':
|
||||
return False
|
||||
if self.kind == 'static type error':
|
||||
return self.run_arch.HasFatalTypeErrors()
|
||||
return False
|
||||
|
||||
|
||||
class StandardTestConfiguration(test.TestConfiguration):
|
||||
LEGAL_KINDS = set(['compile-time error',
|
||||
'runtime error',
|
||||
|
@ -106,7 +58,7 @@ class StandardTestConfiguration(test.TestConfiguration):
|
|||
if tags:
|
||||
return []
|
||||
else:
|
||||
return [BrowserTestCase(
|
||||
return [test_case.BrowserTestCase(
|
||||
self.context, test_path, filename, False, mode, arch)]
|
||||
else:
|
||||
tests = []
|
||||
|
@ -115,18 +67,11 @@ class StandardTestConfiguration(test.TestConfiguration):
|
|||
kind, test_source = tags[tag]
|
||||
if not self.Contains(path, test_path + [tag]):
|
||||
continue
|
||||
tests.append(MultiTestCase(self.context,
|
||||
test_path + [tag],
|
||||
test_source,
|
||||
kind,
|
||||
mode,
|
||||
arch))
|
||||
tests.append(test_case.MultiTestCase(self.context,
|
||||
test_path + [tag], test_source, kind, mode, arch))
|
||||
else:
|
||||
tests.append(StandardTestCase(self.context,
|
||||
test_path,
|
||||
filename,
|
||||
mode,
|
||||
arch))
|
||||
tests.append(test_case.StandardTestCase(self.context,
|
||||
test_path, filename, mode, arch))
|
||||
return tests
|
||||
|
||||
def ListTests(self, current_path, path, mode, arch):
|
||||
|
@ -201,12 +146,15 @@ class StandardTestConfiguration(test.TestConfiguration):
|
|||
tests['none'] = ('', test_filename)
|
||||
return tests
|
||||
|
||||
class BrowserTestCase(StandardTestCase):
|
||||
class BrowserTestCase(test_case.StandardTestCase):
|
||||
def __init__(self, context, path, filename,
|
||||
fatal_static_type_errors, mode, arch):
|
||||
super(BrowserTestCase, self).__init__(context, path, filename, mode, arch)
|
||||
super(test_case.BrowserTestCase, self).__init__(context, path, filename, mode, arch)
|
||||
self.fatal_static_type_errors = fatal_static_type_errors
|
||||
|
||||
def IsBatchable(self):
|
||||
return True
|
||||
|
||||
def Run(self):
|
||||
command = self.run_arch.GetCompileCommand(self.fatal_static_type_errors)
|
||||
if command != None:
|
||||
|
@ -253,12 +201,9 @@ class BrowserTestConfiguration(StandardTestConfiguration):
|
|||
test_path = current_path + relative + [os.path.splitext(f)[0]]
|
||||
if not self.Contains(path, test_path):
|
||||
continue
|
||||
tests.append(BrowserTestCase(self.context,
|
||||
test_path,
|
||||
join(root, f),
|
||||
self.fatal_static_type_errors,
|
||||
mode,
|
||||
arch))
|
||||
tests.append(test_case.BrowserTestCase(self.context,
|
||||
test_path, join(root, f), self.fatal_static_type_errors, mode,
|
||||
arch))
|
||||
atexit.register(lambda: self._cleanup(tests))
|
||||
return tests
|
||||
|
||||
|
@ -266,38 +211,6 @@ class BrowserTestConfiguration(StandardTestConfiguration):
|
|||
return name.endswith('_tests.dart')
|
||||
|
||||
|
||||
class CompilationTestCase(test.TestCase):
|
||||
""" Run the dartc compiler on a given top level dart file """
|
||||
def __init__(self, path, context, filename, mode, arch):
|
||||
super(CompilationTestCase, self).__init__(context, path)
|
||||
self.filename = filename
|
||||
self.mode = mode
|
||||
self.arch = arch
|
||||
self.run_arch = run.GetArchitecture(self.arch, self.mode,
|
||||
self.filename)
|
||||
self.temp_dir = tempfile.mkdtemp(prefix='dartc-output-')
|
||||
|
||||
def IsNegative(self):
|
||||
return False
|
||||
|
||||
def GetLabel(self):
|
||||
return "%s/%s %s" % (self.mode, self.arch, '/'.join(self.path))
|
||||
|
||||
def GetCommand(self):
|
||||
cmd = self.context.GetDartC(self.mode, self.arch);
|
||||
cmd += self.context.flags
|
||||
cmd += ['-check-only',
|
||||
'-fatal-type-errors',
|
||||
'-Werror',
|
||||
'-out', self.temp_dir,
|
||||
self.filename]
|
||||
|
||||
return cmd
|
||||
|
||||
def GetName(self):
|
||||
return self.path[-1]
|
||||
|
||||
|
||||
class CompilationTestConfiguration(test.TestConfiguration):
|
||||
""" Configuration that searches specific directories for apps to compile
|
||||
|
||||
|
@ -324,7 +237,7 @@ class CompilationTestConfiguration(test.TestConfiguration):
|
|||
if ((not self.Contains(path, test_path))
|
||||
or (not self.IsTest(test_dart_file))):
|
||||
continue
|
||||
tests.append(CompilationTestCase(test_path,
|
||||
tests.append(test_case.CompilationTestCase(test_path,
|
||||
self.context,
|
||||
test_dart_file,
|
||||
mode,
|
||||
|
@ -359,7 +272,3 @@ class CompilationTestConfiguration(test.TestConfiguration):
|
|||
if not utils.Daemonize(): return
|
||||
os.execlp('rm', *(['rm', '-rf'] + [t.temp_dir for t in tests]))
|
||||
raise
|
||||
|
||||
|
||||
def GetConfiguration(context, root):
|
||||
return CompilationTestConfiguration(context, root)
|
Loading…
Reference in a new issue