-
-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
edit namespace not resolving in child shell #1196
Comments
Yes, edit is only available in interactive sessions.
…On Sat, 12 Dec 2020 at 21:01, Steve Blundy ***@***.***> wrote:
When a script is run with elvish script.elv, the edit: namespace isn't
resolving correctly. My script is failing with:
Exception: exec: "edit:complete-filename": executable file not found in
$PATH
Reproduction steps:
$ elvish -c 'resolve edit:complete-filename'
▶ '(external edit:complete-filename)'
$ resolve edit:complete-filename
▶ '$edit:complete-filename~'
$ resolve has-key
▶ '$has-key~'
$ elvish -c 'resolve has-key'
▶ '$has-key~'
$ resolve edit:complete-getopt
▶ '$edit:complete-getopt~'
$ elvish -c 'resolve edit:complete-getopt'
▶ '(external edit:complete-getopt)'
$ use math
$ math:log 1
▶ (float64 0)
$ elvish -c 'use math
math:log 1'
▶ (float64 0)
elvish -version: 0.14.1
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1196>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAIA3BP3XWXQZKETUSDRTLSUPD2TANCNFSM4UYSFSBA>
.
|
This is happening in a test script for a completer function. Is there anyway to turn off this behavior or to inject a stub when it's run in non-interactive sessions? |
@sblundy what you should do is load your test script as a library (instead of running it as an external process), then you can run any necessary functions from your interactive shell and have full access to all the namespaces. |
If I understand correctly your real question is how to write unit tests for completions. Ideally it should be possible to run such tests in a manner similar to @zzamboni, You're probably the only one who has written non-trivial completions for Elvish. Haven't you ever wanted to be able to write tests for them that could be run in an automated manner (e.g., a CI like environment)? |
That runs afoul of namespace caching. If you run the test, changes something, then re-import and run the tests again, you'll get the same result as the first time. You can run I stuck this hack in the completion code. It's works but is sub-optimal.
|
@krader1961 @sblundy you are both right that this is suboptimal and makes testing harder. What I have done while developing my completions is just test interactively, starting a new subshell every time. This was discussed some time ago, but I can't find the reference now. I believe @xiaq said at the time he would think about taking functions not directly related to the editor out of |
When a script is run with
elvish script.elv
, theedit:
namespace isn't resolving correctly. My script is failing with:Reproduction steps:
elvish -version
: 0.14.1The text was updated successfully, but these errors were encountered: