# glsl-testify

> Test your GLSL shaders using GLSL!

Latest version **1.0.0** (published 2014-07-17) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install glsl-testify
pnpm add glsl-testify
yarn add glsl-testify
bun add glsl-testify
```

Provides the command `glsl-testify`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2014-07-17 |
| First published | 2014-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | glsl, gl-modules, webgl, shader, test, tap, output |

## Links

- npm: https://www.npmjs.com/package/glsl-testify
- Repository: https://github.com/hughsk/glsl-testify
- Issues: https://github.com/hughsk/glsl-testify/issues
- npm.io page: https://npm.io/package/glsl-testify

## Dependencies (13)

- [shoe](https://npm.io/package/shoe.md) 0.0.15
- [split](https://npm.io/package/split.md) ^0.3.0
- [opener](https://npm.io/package/opener.md) ^1.3.0
- [new-from](https://npm.io/package/new-from.md) 0.0.3
- [through2](https://npm.io/package/through2.md) ^0.5.1
- [gl-shader](https://npm.io/package/gl-shader.md) ^3.0.0
- [gl-context](https://npm.io/package/gl-context.md) ^0.1.0
- [glsl-parser](https://npm.io/package/glsl-parser.md) ^1.0.1
- [canvas-pixels](https://npm.io/package/canvas-pixels.md) 0.0.0
- [concat-stream](https://npm.io/package/concat-stream.md) ^1.4.6
- [glsl-deparser](https://npm.io/package/glsl-deparser.md) ^1.0.0
- [a-big-triangle](https://npm.io/package/a-big-triangle.md) 0.0.0
- [glsl-tokenizer](https://npm.io/package/glsl-tokenizer.md) ^1.1.1

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-07-17

## README

# glsl-testify [![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)

[![NPM](https://nodei.co/npm/glsl-testify.png)](https://nodei.co/npm/glsl-testify/)

Test your GLSL shaders using GLSL!

glsl-testify allows you to write tests inside your GLSL shaders, which can then be
easily executed using the included CLI tool or manually run using the module
API.

## Writing a Test

To create a test, simply define a function in your shader that begins with `test`,
and returns a `bool`, e.g.:

``` glsl
bool test_will_pass() {
  return true;
}
```

If the function returns `true`, then the test is considered passed. glsl-testify
works by generating a shader for each test, and then checking the result of
rendering to a single pixel: a pass is white, and a fail is black.

Using the module API, you'll get back this collection of shaders directly, meaning
that you get the flexibility to work with said shaders however you please.

## CLI Usage

```
Usage: glsl-testify [file]

Takes a testable GLSL shader as input, spawning a temporary browser
window and runs the tests without any uniforms. Outputs TAP, so
you can pass this on to other testing tools to deal with the results.
```

For example:

``` bash
# Install your tools globally
npm install -g glsl-testify tap-spec
# Pipe your shader through glsl-testify to tap-spec
# for nice test output!
cat example.glsl | glsl-testify | tap-spec
```

While the current tool opens a browser window to run the test, hopefully
in the future we'll be able to get WebGL running headlessly in node
for easier CI.

![example](http://imgur.com/llQPhBp.png)

## Module Usage

### stream = testify(done(err, tests))

Returns a stream that expects input from
[glsl-parser](http://github.com/chrisdickinson/glsl-parser), calling
`done` with the resulting test shaders when complete.

For example:

``` javascript
var tokenizer = require('glsl-tokenizer')
var testify = require('glsl-testify')
var parser = require('glsl-parser')
var fs = require('fs')

fs.createReadStream('example.glsl')
  .pipe(tokenizer())
  .pipe(parser())
  .pipe(testify(function(err, testShaders) {
    if (err) throw err

    console.log(testShaders.test_pass)
    console.log(testShaders.test_fail)
  }))
```

Each test is simply a fragment shader which will draw white if
the test has passed or black if it fails. You can run these using
your own tools, for example to add uniform/attributes as input.

## License

MIT. See [LICENSE.md](http://github.com/hughsk/glsl-testify/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/glsl-testify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
