WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
17531
Add interactive mode to testkjs
https://bugs.webkit.org/show_bug.cgi?id=17531
Summary
Add interactive mode to testkjs
Sam Weinig
Reported
2008-02-25 00:28:36 PST
Adding an interactive shell to testkjs seems like the next step. Let's do it!
Attachments
First stab at it
(8.03 KB, patch)
2008-02-25 00:35 PST
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Proposed patch
(10.41 KB, patch)
2008-06-09 01:20 PDT
,
Cameron Zwarich (cpst)
darin
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2008-02-25 00:35:40 PST
Created
attachment 19341
[details]
First stab at it Here is a first stab at an interactive shell mode. If the platform you are on has readline support (currently I only have it set for Darwin, since I know it does, but the automake platforms can be made to check for it too) I use it and make use of the history, otherwise we just use getchar. The way interactive mode works with files is that all the files are run first, and if they succeed, we go into interactive mode. There are some names I don't especially like in this patch (the Options struct for one, not really sure we even need it) and I think it has gotten to the point where we need a more fleshed out usage message. All in all though, this is pretty close.
Sam Weinig
Comment 2
2008-02-25 00:40:13 PST
Another feature I would like to add to the interactive mode, though not necessarily in this first version, is good autocompletion support (js keywords, variables in scope). This can be done rather easily using readline. It also just occurred to me. Does it make sense to enter interactive mode if -p has been supplied.
Mark Rowe (bdash)
Comment 3
2008-02-25 04:01:20 PST
+#if HAVE(asREADLINE) I wonder if the default behaviour for running testkjs with no arguments should be to drop into the interactive shell? With your patch it doesn't seem possible to get into interactive mode without executing code from some file first. That may be a useful mode for inspecting the state of a completed script, but based on experiences using Python's interactive interpreter I feel it may be less commonly used than interactive mode without executing any code from a file.
Cameron Zwarich (cpst)
Comment 4
2008-06-09 01:20:57 PDT
Created
attachment 21590
[details]
Proposed patch Here is a cleaned up version of Sam's patch. I made the prompt string the same as SpiderMonkey's, and I made it enter interactive mode if no files are specified.
Darin Adler
Comment 5
2008-06-09 06:51:08 PDT
Comment on
attachment 21590
[details]
Proposed patch +static const char* interactivePrompt = "> "; This should be static const char[] or static const char* const. The declaration as-is asks for a non-const global pointing to a const string. + fprintf(stderr, " -p Prints formatted source code\n"); I think this option is a little silly now that it does no formatting and just spits the code out as-is. r=me
Mark Rowe (bdash)
Comment 6
2008-06-09 09:43:15 PDT
-p still seems to do a relatively good job. Oliver explained to me why it may give worse results than before on some input, but in my quick test with some crazy-obfuscated gmail source code it gave reasonable results.
Cameron Zwarich (cpst)
Comment 7
2008-06-09 10:02:27 PDT
(In reply to
comment #5
)
> (From update of
attachment 21590
[details]
[edit]) > +static const char* interactivePrompt = "> "; > > This should be static const char[] or static const char* const. The declaration > as-is asks for a non-const global pointing to a const string.
Thanks. I meant to make it a static const char[].
Cameron Zwarich (cpst)
Comment 8
2008-06-09 10:12:01 PDT
Landed in
r34470
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug