Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/shaderc
Path: blob/main/glslc/test/expect_unittest.py
1560 views
1
# Copyright 2019 The Shaderc Authors. All rights reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
# http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
"""Tests for the expect module."""
15
16
17
import expect
18
from glslc_test_framework import TestStatus
19
import re
20
import unittest
21
22
23
class TestStdoutMatchADotC(expect.StdoutMatch):
24
expected_stdout = re.compile('a.c')
25
26
27
class TestExpect(unittest.TestCase):
28
def test_get_object_name(self):
29
"""Tests get_object_filename()."""
30
source_and_object_names = [('a.vert', 'a.vert.spv'),
31
('b.frag', 'b.frag.spv'),
32
('c.tesc', 'c.tesc.spv'),
33
('d.tese', 'd.tese.spv'),
34
('e.geom', 'e.geom.spv'),
35
('f.comp', 'f.comp.spv'),
36
('file', 'file.spv'), ('file.', 'file.spv'),
37
('file.uk',
38
'file.spv'), ('file.vert.',
39
'file.vert.spv'),
40
('file.vert.bla',
41
'file.vert.spv')]
42
actual_object_names = [
43
expect.get_object_filename(f[0]) for f in source_and_object_names
44
]
45
expected_object_names = [f[1] for f in source_and_object_names]
46
47
self.assertEqual(actual_object_names, expected_object_names)
48
49
def test_stdout_match_regex_has_match(self):
50
test = TestStdoutMatchADotC()
51
status = TestStatus(
52
test_manager=None,
53
returncode=0,
54
stdout=b'0abc1',
55
stderr=None,
56
directory=None,
57
inputs=None,
58
input_filenames=None)
59
self.assertTrue(test.check_stdout_match(status)[0])
60
61
def test_stdout_match_regex_no_match(self):
62
test = TestStdoutMatchADotC()
63
status = TestStatus(
64
test_manager=None,
65
returncode=0,
66
stdout=b'ab',
67
stderr=None,
68
directory=None,
69
inputs=None,
70
input_filenames=None)
71
self.assertFalse(test.check_stdout_match(status)[0])
72
73
def test_stdout_match_regex_empty_stdout(self):
74
test = TestStdoutMatchADotC()
75
status = TestStatus(
76
test_manager=None,
77
returncode=0,
78
stdout=b'',
79
stderr=None,
80
directory=None,
81
inputs=None,
82
input_filenames=None)
83
self.assertFalse(test.check_stdout_match(status)[0])
84
85