def _populate_profile_xts(profile): fpath = os.path.join(X_TEST_SUITE, 'xts5') for dirpath, _, filenames in os.walk(fpath): for fname in filenames: # only look at the .m test files testname, ext = os.path.splitext(fname) if ext != '.m': continue # incrementing number generator counts = itertools.count(start=1) # Walk the file looking for >>ASSERTION, each of these corresponds # to a generated subtest, there can be multiple subtests per .m # file with open(os.path.join(dirpath, fname), 'r') as rfile: for line in rfile: if line.startswith('>>ASSERTION'): num = next(counts) group = grouptools.join( grouptools.from_path( os.path.relpath(dirpath, X_TEST_SUITE)), testname, str(num)) profile.test_list[group] = XTSTest( os.path.join(dirpath, testname), testname, num)
def test_from_path_posix(): """grouptools.from_path: converts / to {seperator} in posix paths.""" # Since we already have tests for grouptools.join we can trust it to do the # right thing here. This also means that the test doesn't need to be # updated if the separator is changed. nt.assert_equal(grouptools.from_path('foo/bar'), grouptools.join('foo', 'bar'))
def add_shader_test(shader): """Given an adder, creates a group and adds a shader test.""" abs_path = os.path.abspath(shader) if os.path.commonprefix([abs_path, GENERATED_TESTS_DIR]) == GENERATED_TESTS_DIR: installpath = os.path.relpath(shader, gen_basepath) else: installpath = None dirpath = os.path.dirname(shader) groupname = grouptools.from_path(os.path.relpath( dirpath, GENERATED_TESTS_DIR if installpath else TESTS_DIR)) testname = os.path.splitext(os.path.basename(shader))[0] profile.test_list[grouptools.join(groupname, testname)] = \ ShaderTest.new(shader, installpath)
def populateTests(runfile): "Read a .run file, adding any .test files to the profile" with open(runfile, 'r') as f: for line in f.readlines(): # Ignore comments and whitespace line = line.strip() if line.startswith('#') or line == '': continue newpath = path.join(path.dirname(runfile), line) if line.endswith('.run'): populateTests(newpath) else: # Add the .test file group = grouptools.join( 'es3conform', grouptools.from_path(path.relpath(newpath, gtfroot))) profile.test_list[group] = GTFTest(newpath)
def add_shader_test(shader): """Given an adder, creates a group and adds a shader test.""" for d in (TESTS_DIR, GENERATED_TESTS_DIR,): s = os.path.abspath(os.path.join(d, shader)) if os.path.exists(s): basedir = d abs_path = s break dirpath, filename = os.path.split(os.path.join(basedir, shader)) dirname = os.path.relpath(dirpath, basepath) filepath = os.path.join(dirname, filename) if os.path.commonprefix([abs_path, GENERATED_TESTS_DIR]) == GENERATED_TESTS_DIR: installpath = os.path.relpath(filepath, gen_basepath) else: installpath = None groupname = grouptools.from_path(os.path.relpath(dirpath, basedir)) testname = os.path.splitext(os.path.basename(shader))[0] group = grouptools.join(groupname, testname) profile.test_list[group] = ShaderTest.new(filepath, installpath)
def test_from_path_dot(): """grouptools.from_path: should convert '.' into ''.""" nt.assert_equal(grouptools.from_path('.'), '')
def test_from_path_nt(): """grouptools.from_path: converts \\ to {seperator} in nt paths.""" nt.assert_equal(grouptools.from_path('foo\\bar'), grouptools.join('foo', 'bar'))
from framework.test.glsl_parser_test import GLSLParserTest, GLSLParserNoConfigError from framework.test.piglit_test import ASMParserTest, ROOT_DIR from .py_modules.constants import GENERATED_TESTS_DIR, TESTS_DIR __all__ = ['profile'] profile = TestProfile() # Find and add all shader tests. basepath = os.path.normpath(os.path.join(TESTS_DIR, '..')) gen_basepath = os.path.relpath(os.path.join(GENERATED_TESTS_DIR, '..'), basepath) for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]: isgenerated = basedir == GENERATED_TESTS_DIR for dirpath, _, filenames in os.walk(basedir): groupname = grouptools.from_path(os.path.relpath(dirpath, basedir)) for filename in filenames: testname, ext = os.path.splitext(filename) if ext in ['.vert', '.tesc', '.tese', '.geom', '.frag', '.comp']: dirname = os.path.relpath(dirpath, basepath) filepath = os.path.join(dirname, filename) if isgenerated: installpath = os.path.relpath(filepath, gen_basepath) else: installpath = None try: test = GLSLParserTest.new(filepath, installpath) except GLSLParserNoConfigError: # In the event that there is no config assume that it is a # legacy test, and continue
def test_dot(self): """grouptools.from_path: should convert '.' into ''.""" assert grouptools.from_path('.') == ''
def test_posix(self): """grouptools.from_path: converts / to separator in posix paths.""" # Since we already have tests for grouptools.join we can trust it to do # the right thing here. This also means that the test doesn't need to # be updated if the separator is changed. assert grouptools.from_path('foo/bar') == grouptools.join('foo', 'bar')
def test_nt(self): """grouptools.from_path: converts \\ to separator in nt paths.""" assert grouptools.from_path('foo\\bar') == grouptools.join( 'foo', 'bar')
__all__ = ['profile'] profile = TestProfile() shader_tests = collections.defaultdict(list) # Find and add all shader tests. basepath = os.path.normpath(os.path.join(TESTS_DIR, '..')) gen_basepath = os.path.relpath(os.path.join(GENERATED_TESTS_DIR, '..'), basepath) for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]: isgenerated = basedir == GENERATED_TESTS_DIR for dirpath, _, filenames in os.walk(basedir): groupname = grouptools.from_path(os.path.relpath(dirpath, basedir)) for filename in filenames: testname, ext = os.path.splitext(filename) if ext == '.shader_test': dirname = os.path.relpath(dirpath, basepath) filepath = os.path.join(dirname, filename) if isgenerated: installpath = os.path.relpath(filepath, gen_basepath) else: installpath = None if OPTIONS.process_isolation: test = ShaderTest.new(filepath, installpath) else: shader_tests[groupname].append((filepath, installpath)) continue
from .py_modules.constants import GENERATED_TESTS_DIR, TESTS_DIR __all__ = ['profile'] profile = TestProfile() shader_tests = collections.defaultdict(list) # Find and add all shader tests. basepath = os.path.normpath(os.path.join(TESTS_DIR, '..')) gen_basepath = os.path.relpath(os.path.join(GENERATED_TESTS_DIR, '..'), basepath) for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]: isgenerated = basedir == GENERATED_TESTS_DIR for dirpath, _, filenames in os.walk(basedir): groupname = grouptools.from_path(os.path.relpath(dirpath, basedir)) for filename in filenames: testname, ext = os.path.splitext(filename) if ext == '.shader_test': dirname = os.path.relpath(dirpath, basepath) filepath = os.path.join(dirname, filename) if isgenerated: installpath = os.path.relpath(filepath, gen_basepath) else: installpath = None if OPTIONS.process_isolation: test = ShaderTest.new(filepath, installpath) else: shader_tests[groupname].append((filepath, installpath)) continue