From 1b4339ddbf4f6f6740f5f585770c4dde22f88c63 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 15 Sep 2019 01:49:09 -0400 Subject: [PATCH] Add tests directory. --- README.md | 4 ++-- src/DuktapeEngine.cpp | 3 +++ src/Prototype.cpp | 2 ++ tests/process_error.js | 4 ++++ tests/run_error.js | 1 + tests/syntax_error.js | 1 + 6 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/process_error.js create mode 100644 tests/run_error.js create mode 100644 tests/syntax_error.js diff --git a/README.md b/README.md index ab118cd..64bfad6 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ display(message) For CV generators and processors, 256 is reasonable. For sequencers, 32 is reasonable since process() will be called every 0.7ms with a 44100kHz sample rate, which will capture 1ms-long triggers. For audio generators and processors, 1-8 is recommended, but it will consume lots of CPU. -If this is too slow for your purposes, you should just write a C++ plugin. +If this is too slow for your purposes, consider writing a C++ plugin, since native VCV Rack plugins are 10-100 faster. */ config.frameDivider // 32 @@ -86,7 +86,7 @@ function process(args) { ## License -All **source code** is copyright © 2019 Andrew Belt and licensed under the [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause). +All **source code** is copyright © 2019 VCV Prototype Maintainers and licensed under the [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause). The **panel graphics** in the `res` directory are copyright © 2019 [Grayscale](http://grayscale.info/) and licensed under [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/). You may not distribute modified adaptations of these graphics. diff --git a/src/DuktapeEngine.cpp b/src/DuktapeEngine.cpp index 7ab7b84..1956d8a 100644 --- a/src/DuktapeEngine.cpp +++ b/src/DuktapeEngine.cpp @@ -63,6 +63,7 @@ struct DuktapeEngine : ScriptEngine { duk_push_string(ctx, path.c_str()); if (duk_pcompile_lstring_filename(ctx, 0, script.c_str(), script.size()) != 0) { const char* s = duk_safe_to_string(ctx, -1); + rack::WARN("duktape: %s", s); setMessage(s); duk_pop(ctx); return -1; @@ -70,6 +71,7 @@ struct DuktapeEngine : ScriptEngine { // Execute function if (duk_pcall(ctx, 0)) { const char* s = duk_safe_to_string(ctx, -1); + rack::WARN("duktape: %s", s); setMessage(s); duk_pop(ctx); return -1; @@ -209,6 +211,7 @@ struct DuktapeEngine : ScriptEngine { // Call process function if (duk_pcall(ctx, 1)) { const char* s = duk_safe_to_string(ctx, -1); + rack::WARN("duktape: %s", s); setMessage(s); duk_pop(ctx); return -1; diff --git a/src/Prototype.cpp b/src/Prototype.cpp index 84d7deb..2b37d86 100644 --- a/src/Prototype.cpp +++ b/src/Prototype.cpp @@ -73,6 +73,7 @@ struct Prototype : Module { // Check for certain inside the mutex if (scriptEngine) { if (scriptEngine->process(scriptArgs)) { + WARN("Script %s process() failed. Stopped script.", path.c_str()); clearScriptEngine(); return; } @@ -108,6 +109,7 @@ struct Prototype : Module { clearScriptEngine(); // Get ScriptEngine from path extension if (path == "") { + // Empty path means no script is requested. Fail silently. return; } INFO("Loading script %s", path.c_str()); diff --git a/tests/process_error.js b/tests/process_error.js new file mode 100644 index 0000000..fcf95a3 --- /dev/null +++ b/tests/process_error.js @@ -0,0 +1,4 @@ + +function process(args) { + args.test() +} \ No newline at end of file diff --git a/tests/run_error.js b/tests/run_error.js new file mode 100644 index 0000000..8be6379 --- /dev/null +++ b/tests/run_error.js @@ -0,0 +1 @@ +test() diff --git a/tests/syntax_error.js b/tests/syntax_error.js new file mode 100644 index 0000000..e1512f7 --- /dev/null +++ b/tests/syntax_error.js @@ -0,0 +1 @@ +.test() \ No newline at end of file