( self )
| 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 | |
| 152 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected