MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testClear

Method testClear

test/IECoreGL/ShaderLoaderTest.py:113–149  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

111 self.assertTrue( "thisShaderDoesntExist" in mh.messages[0].message )
112
113 def testClear( self ) :
114
115 temporaryDirectory = tempfile.mkdtemp( prefix="IECoreGL" )
116 sp = IECore.SearchPath( temporaryDirectory )
117 l = IECoreGL.ShaderLoader( sp )
118
119 f = open( os.path.join( temporaryDirectory, "testShader.frag" ), 'w' )
120 f.write(
121 """void main()
122 {
123 gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
124 }"""
125 )
126 f.close()
127
128 s = l.load( "testShader" )
129
130 f = open(os.path.join( temporaryDirectory, "testShader.frag" ), 'w' )
131 f.write(
132 """void main()
133 {
134 gl_FragColor = vec4( 0.0, 1.0, 0.0, 1.0 );
135 }"""
136 )
137 f.close()
138
139 # Source is updated, but we will still reuse the cache
140 s2 = l.load( "testShader" )
141 self.assertTrue( s.isSame( s2 ) )
142
143 l.clear()
144
145 # After clearing, the shader is now updated. ( Ideally we would test the modified functionality of the shader here, but that seems hard. )
146 s3 = l.load( "testShader" )
147 self.assertTrue( not s.isSame( s3 ) )
148
149 shutil.rmtree( temporaryDirectory )
150
151
152if __name__ == "__main__":

Callers

nothing calls this directly

Calls 7

loadMethod · 0.95
clearMethod · 0.95
SearchPathMethod · 0.80
ShaderLoaderMethod · 0.80
joinMethod · 0.80
closeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected