Testing code that needs to run in its own V8 VM

12 views
Skip to first unread message

rtda...@gmail.com

unread,
Jan 21, 2012, 5:33:14 PM1/21/12
to Google JS Test
I have a C++ project that embeds V8 and executes JavaScript files,
much like Node.js. Is there any chance of being able to use your
framework?

Aaron Jacobs

unread,
Jan 22, 2012, 4:19:14 PM1/22/12
to google-...@googlegroups.com
What exactly are you trying to test? Is it the C++ part or the JS
part? If it's the JS part, then yes you can use gjstest to test it
like any other JS code. The same restrictions apply though–you'll have
to mock out anything that isn't provided by your code or built in to
V8.

Aaron

rtda...@gmail.com

unread,
Jan 23, 2012, 1:14:31 AM1/23/12
to Google JS Test
I'd like to test the JS code without mocking anything out. As an
executable, gjstest can't do this, but I was hoping I could link with
a library that provides the testing functionality in some form.

rtda...@gmail.com

unread,
Jan 23, 2012, 3:07:26 AM1/23/12
to Google JS Test
(I want to add the google-js-test JS stuff to my v8 Context.)

Aaron Jacobs

unread,
Jan 23, 2012, 4:28:42 PM1/23/12
to google-...@googlegroups.com
On Mon, Jan 23, 2012 at 5:14 PM, rtda...@gmail.com
<rtda...@gmail.com> wrote:
> I'd like to test the JS code without mocking anything out. As an
> executable, gjstest can't do this, but I was hoping I could link with
> a library that provides the testing functionality in some form.

This isn't officially supported, but you could probably hack it
together. (No promises, though.) Take a look at the
use_global_namespace target here, which brings in all of the things
needed by tests:

http://code.google.com/p/google-js-test/source/browse/gjstest/internal/js/targets.mk

Also browse gjstest/internal/cpp, which sets up magic functions needed
for the JS to call into the C++.

Reply all
Reply to author
Forward
0 new messages