Skip to content

Commit

Permalink
feat: isolate glsl unit tests that fail and report on them.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhouston committed Jul 29, 2020
1 parent da01669 commit ff0e595
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions src/examples/units/glsl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,48 @@ async function init(): Promise<null> {
let totalDuplicates = 0;

glslTestSuites.forEach((glslUnitTest) => {
const passMaterial = new ShaderMaterial(vertexSource, glslUnitTest.source);
const unitProgram = makeProgramFromShaderMaterial(context, passMaterial);

framebuffer.clear(BufferBit.All);
renderBufferGeometry(framebuffer, unitProgram, unitUniforms, bufferGeometry);

const result = readPixelsFromFramebuffer(framebuffer) as Uint8Array;

const passIds = [];
const failureIds = [];
const duplicateIds = [];

for (let i = 0; i < result.length; i += 4) {
const runResult = result[i + 2];
const id = i / 4;
switch (runResult) {
case 0:
failureIds.push(id);
break;
case 1:
passIds.push(id);
break;
case 3:
duplicateIds.push(id);
break;
let compileError = undefined;

try {
const passMaterial = new ShaderMaterial(vertexSource, glslUnitTest.source);
const unitProgram = makeProgramFromShaderMaterial(context, passMaterial);

framebuffer.clear(BufferBit.All);
renderBufferGeometry(framebuffer, unitProgram, unitUniforms, bufferGeometry);

const result = readPixelsFromFramebuffer(framebuffer) as Uint8Array;

for (let i = 0; i < result.length; i += 4) {
const runResult = result[i + 2];
const id = i / 4;
switch (runResult) {
case 0:
failureIds.push(id);
break;
case 1:
passIds.push(id);
break;
case 3:
duplicateIds.push(id);
break;
}
}
} catch (e) {
totalFailures++;
compileError = e;
}

totalPasses += passIds.length;
totalFailures += failureIds.length;
totalDuplicates += duplicateIds.length;

output.push(`${glslUnitTest.name}.test.glsl: ${passIds.length + failureIds.length + duplicateIds.length} tests`);
if (failureIds.length == 0 && duplicateIds.length == 0) {
if (compileError !== undefined) {
output.push(` COMPILE FAILED: ${compileError.message}`);
} else if (failureIds.length === 0 && duplicateIds.length === 0) {
output.push(" ALL PASSED");
}
if (failureIds.length > 0) {
Expand Down

0 comments on commit ff0e595

Please sign in to comment.