Path: blob/main/glslc/test/expect_unittest.py
1560 views
# Copyright 2019 The Shaderc Authors. All rights reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License");3# you may not use this file except in compliance with the License.4# You may obtain a copy of the License at5#6# http://www.apache.org/licenses/LICENSE-2.07#8# Unless required by applicable law or agreed to in writing, software9# distributed under the License is distributed on an "AS IS" BASIS,10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11# See the License for the specific language governing permissions and12# limitations under the License.13"""Tests for the expect module."""141516import expect17from glslc_test_framework import TestStatus18import re19import unittest202122class TestStdoutMatchADotC(expect.StdoutMatch):23expected_stdout = re.compile('a.c')242526class TestExpect(unittest.TestCase):27def test_get_object_name(self):28"""Tests get_object_filename()."""29source_and_object_names = [('a.vert', 'a.vert.spv'),30('b.frag', 'b.frag.spv'),31('c.tesc', 'c.tesc.spv'),32('d.tese', 'd.tese.spv'),33('e.geom', 'e.geom.spv'),34('f.comp', 'f.comp.spv'),35('file', 'file.spv'), ('file.', 'file.spv'),36('file.uk',37'file.spv'), ('file.vert.',38'file.vert.spv'),39('file.vert.bla',40'file.vert.spv')]41actual_object_names = [42expect.get_object_filename(f[0]) for f in source_and_object_names43]44expected_object_names = [f[1] for f in source_and_object_names]4546self.assertEqual(actual_object_names, expected_object_names)4748def test_stdout_match_regex_has_match(self):49test = TestStdoutMatchADotC()50status = TestStatus(51test_manager=None,52returncode=0,53stdout=b'0abc1',54stderr=None,55directory=None,56inputs=None,57input_filenames=None)58self.assertTrue(test.check_stdout_match(status)[0])5960def test_stdout_match_regex_no_match(self):61test = TestStdoutMatchADotC()62status = TestStatus(63test_manager=None,64returncode=0,65stdout=b'ab',66stderr=None,67directory=None,68inputs=None,69input_filenames=None)70self.assertFalse(test.check_stdout_match(status)[0])7172def test_stdout_match_regex_empty_stdout(self):73test = TestStdoutMatchADotC()74status = TestStatus(75test_manager=None,76returncode=0,77stdout=b'',78stderr=None,79directory=None,80inputs=None,81input_filenames=None)82self.assertFalse(test.check_stdout_match(status)[0])838485