probmods / webppl-viz

Visualization for WebPPL
http://probmods.github.io/webppl-viz/
Other
14 stars 9 forks source link

run test on all examples in docs/index.html #79

Closed hereneric closed 7 years ago

hereneric commented 7 years ago

To run this test, cd to the test-auto directory (need to cd because of bash in test-viz.js), and run node test-viz.js

New files: test-viz.js: the script running tests and showing results svgs.json: saves an object, the keys are svg names, the value is the example that generates the key correct-svgs/: a directory of all correct svgs for check

Also changed a little bit of index.js, now the runningInBrowser function seems to work better?

longouyang commented 7 years ago

I cloned your repository and tried running node test-viz.js but got errors:

Executing: webppl test_js/1.wppl --require ../.. --random-seed 1
Command failed: webppl test_js/1.wppl --require ../.. --random-seed 1
/Users/long/Desktop/webppl-viz/node_modules/units-css/lib/utilities.js:114
  return utilities.getCreatedElementWidth(document.body, {
                                          ^

ReferenceError: document is not defined
    at /Users/long/Desktop/webppl-viz/node_modules/units-css/lib/utilities.js:114:43
    at Object.<anonymous> (/Users/long/Desktop/webppl-viz/node_modules/units-css/lib/utilities.js:117:2)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/long/Desktop/webppl-viz/node_modules/units-css/lib/conversions/length.js:6:17)

Executing: webppl test_js/10.wppl --require ../.. --random-seed 1
Command failed: webppl test_js/10.wppl --require ../.. --random-seed 1
/Users/long/Desktop/webppl-viz/node_modules/units-css/lib/utilities.js:114
  return utilities.getCreatedElementWidth(document.body, {

Also, I would like for the testing script to us webppl programmatically as a devDependency rather than calling it using child_process.exec.

hereneric commented 7 years ago

I haven't met this error before. Can you run webppl test_js/1.wppl --require ../.. --random-seed 1 without error?

longouyang commented 7 years ago

No -- I get the same error about document being undefined. Are you maybe using a node package that isn't listed in package.json? jsdom, perhaps?

hereneric commented 7 years ago

That's weird. webppl test_js/1.wppl --require ../.. --random-seed 1 just runs an ordinary webppl script right? So I'm guessing your webppl is not running successfully? My test.js just use native node packages fs, readline, child_process, nothing to do with extra packages like dom or css.

longouyang commented 7 years ago

My webppl works fine -- running npm run test in the webppl directory, all tests pass.

What version of node are you running?

hereneric commented 7 years ago

I'm using v.7.7.1.

longouyang commented 7 years ago

Summarizing our meeting today: the cuplrit is the latest version of canvas, 1.6.5.

1.6.4 works fine, but we now need to figure out how to pin to this version.

hereneric commented 7 years ago

Fixed canvas version problem by shrinkwrap: https://nodejs.org/en/blog/npm/managing-node-js-dependencies-with-shrinkwrap/

Now npm install can figure out the correct version, with the existence of preset npm-shrinkwrap.json.

Got rid of child process exec.

longouyang commented 7 years ago

Paper trail: the canvas issue is under investigation at Automattic/node-canvas#898