wvtest.js: bare minimum changes to make it work with MacOS jsc command.
This isn't pretty, and lacks things like nice-looking stack traces and line
number printouts. But at least you can get pass/fail results.
diff --git a/.gitignore b/.gitignore
index 265b1b2..38d2692 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,4 @@
.*~
*.pyc
help.html
-v8shell
+jsshell
diff --git a/Makefile b/Makefile
index 4c3e927..6a6b181 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,12 @@
all: help.html
-v8shell: v8shell.cc
- g++ -o $@ $< -lv8
+MACOS_JS_PATH=/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc
+jsshell:
+ rm -f $@
+ [ -e "${MACOS_JS_PATH}" ] && \
+ ln -s "${MACOS_JS_PATH}" jsshell || \
+ g++ -o $@ v8shell.cc -lv8
runtests: $(patsubst %.js,%.js.run,$(wildcard t/t*.js))
@@ -11,12 +15,12 @@
markdown $< >$@.new
mv $@.new $@
-%.js.run: %.js v8shell
- ./v8shell wvtest.js $*.js
+%.js.run: %.js jsshell
+ ./jsshell wvtest.js $*.js
-test: v8shell
+test: jsshell
./wvtestrun $(MAKE) runtests
clean:
- rm -f *~ .*~ */*~ */.*~ help.html v8shell
+ rm -f *~ .*~ */*~ */.*~ help.html v8shell jsshell
find . -name '*~' -exec rm -f {} \;
diff --git a/wvtest.js b/wvtest.js
index 3a1008c..3fb8120 100644
--- a/wvtest.js
+++ b/wvtest.js
@@ -4,16 +4,26 @@
function lookup(filename, line) {
var f = files[filename];
if (!f) {
- f = files[filename] = read(filename).split('\n');
+ try {
+ f = files[filename] = read(filename).split('\n');
+ } catch (e) {
+ f = files[filename] = [];
+ }
}
- return f[line-1]; // file line numbers are 1-based
+ return f[line-1] || 'BAD_LINE'; // file line numbers are 1-based
}
+// TODO(apenwarr): Right now this only really works right on chrome.
+// Maybe take some advice from this article:
+// http://stackoverflow.com/questions/5358983/javascript-stack-inspection-on-safari-mobile-ipad
function trace() {
var FILELINE_RE = /[\b\s]\(?([^:\s]+):(\d+)/;
var out = [];
var e = Error().stack;
+ if (!e) {
+ return [['UNKNOWN', 0], ['UNKNOWN', 0]];
+ }
var lines = e.split('\n');
for (i in lines) {
if (i > 2) {