Commit Graph

91 Commits

Author SHA1 Message Date
James McCoy
eb7b2c7912
Fix crash if --embed is used more than once 2018-10-03 07:29:08 -04:00
Justin M. Keyes
51d42917f0 test/win: job_spec: increase jobwait() timeout
powershell is slow, and this timeout is "worst case" so it doesn't make
the tests more costly, only avoids a false-positive.

close #8958
2018-09-05 22:05:05 +02:00
Björn Linse
3d88287e30 tests: introduce screen:expect{...} form 2018-08-27 15:15:49 +02:00
Justin M. Keyes
9625e9da75 startup: delete empty stdin buffer if other files were opened
DWIM: avoid empty buffer 1 when stdin was empty. If other files were
specified at startup, we assume that stdin is only accidentally
not-a-TTY: user did not intend to send text from it.

ref #8560
ref #8561
2018-06-18 21:51:42 +02:00
Justin M. Keyes
d44ed79ccc startup: go to buffer 2 if stdin is empty
If stdin is not a TTY we read it into buffer 1, as text. But if the
stdin pipe is empty, Nvim was most likely invoked for some other reason.
DWIM: select buffer 2 (if it exists). Example:

    echo file1 | xargs nvim

closes #8560
closes #8561
ref https://github.com/equalsraf/neovim-qt/issues/417
2018-06-18 17:51:38 +02:00
Justin M. Keyes
487cf98c0b startup: fix -E/-Es without -u NONE
Before this change, -E/-Es without `-u NONE` reads stdin as Ex commands.
It should always read stdin as text (into buffer 1), like this:

    echo foo | nvim -Es +'%p'
    foo
    echo foo | nvim -Es -u NORC +'%p'
    foo
2018-06-17 14:50:53 +02:00
Justin M. Keyes
9c2099d585 Ex mode: use getexline() instead of getexmodeline()
This changes Ex mode (Q, -e) to work like Vim's "improved Ex mode"
(gQ, -E).  That brings some small behavior differences, but should not
impact most Ex scripts (unless, for example, they depend on mappings
being disabled--but that can be solved for -e by skipping user config).

Before this change:
* the screen test hangs.

After this change:
* Q acts like gQ.
* -e/-es differs from -E/-Es only in its treatment of stdin.

This moves towards potentially removing getexmodeline().
(HINT: That does NOT mean "removing Ex mode", it means removing the
Vi-compatible Ex mode, which differs from Vim's "improved Ex mode" only
in some minor details (e.g. mappings are disabled).)

ref #1089 :-)~
2018-06-17 14:50:53 +02:00
Justin M. Keyes
dc5fdbc758 test: fix startup_spec
This behavior was changed (improved) by 5861dc5966 which actually
makes -E more faithful to Vim's behavior.
2018-06-10 16:27:13 +02:00
Justin M. Keyes
d8c7ff1335 cleanup, test interactive -E 2018-06-04 02:09:28 +02:00
Justin M. Keyes
1f300e08b8 win/startup: remove --literal
Fixes 2 failing tests in startup_spec.lua.

The Windows-only `--literal` option complicates support of "stdin-as-text
+ file-args" (#7679).  Could work around it, but it's not worth
the trouble:
- users have a reasonable (and englightening) alternative: nvim +"n *"
- "always literal" is more consistent/predictable
- avoids platform-specific special-case

Unrelated changes:
- Replace fileno(stdxx) with STDXX_FILENO for consistency (not motivated
  by any observed technical reason).
2018-06-04 02:09:27 +02:00
Justin M. Keyes
4211255c75 startup: allow explicit "-" file arg with --headless 2018-06-04 02:09:27 +02:00
Justin M. Keyes
63058fb5b0 startup: fix -es/-Es so they are actually silent
silent-mode (-es/-Es) has been broken for years.  The workaround up to
now was to include --headless.  But --headless is not equivalent because
it prints all messages, not the limited subset defined by silent-mode.
2018-06-04 02:09:27 +02:00
Justin M. Keyes
51e817dc1b startup: stdin as text instead of commands
Treat stdin as text by default (so the "-" file is not needed):
    echo foo | nvim

It works with file args (implemented in next commit), too:
    echo foo | nvim file1.txt file2.txt

Why? Because:
- Execution of input is (1) almost always unintentional/confusing,
  and (2) potentially destructive.
- Avoids the need for time-delayed warning.  #7659
- The _common_ case is to open text in a buffer, not send commands.

Note:
- Not for Ex-mode (-es) because it is used by scripts.  But maybe `-Es`?
- Not for --headless, because stdio may be a protocol stream and may be
  used for any purpose by stdioopen().

To treat stdin as Normal-mode commands, use `-s -` instead:
    echo ifoo | nvim -s -
Other alternatives:
  - Replay a register. E.g. the following mostly works, except @q aborts
    on any "beep" (e.g. if the cursor can't move).
    nvim -c '%d q|norm @q' -
  - Future: Let `:%source` work with unsaved buffer contents?

closes #2087
closes #7659
2018-06-04 02:07:39 +02:00
Björn Linse
a676c658cc channel: avoid references to non-rooted vimL list with output
likely fixes #7768 #7913

If multiple internal stream callbacks were recieved before vimL
callbacks got called, only invoke one vimL callback with all data.
2018-05-17 19:09:32 +02:00
Justin M. Keyes
77cb14cc6d API: nvim__stats()
Use it to verify fsync() behavior.
2018-04-24 00:44:06 +02:00
Justin M. Keyes
32f3937477 test: fsync() codepaths 2018-04-23 21:29:07 +02:00
Justin M. Keyes
be2a3ddd58
test: "Command-line option -s": avoid indeterminism (#8305)
closes #8303
2018-04-21 03:15:18 +02:00
Justin M. Keyes
7a13611ba2
Merge #8276 'startup: Make -s - read from stdin' 2018-04-17 10:33:36 +02:00
Justin M. Keyes
7598e6cf17
Merge #8120 'test: win: prefer cmd.exe' 2018-04-15 18:16:37 +02:00
b-r-o-c-k
387fbcd95c win: Fix reading from stdin
* Reading from stdin on Windows is fixed in the same way as it was in
  #8267.
* The file_read function was returning without filling the
  destination buffer when it was called with a non-blocking file
  descriptor.
2018-04-14 14:21:36 -05:00
b-r-o-c-k
ad999eaa77 Merge branch 'master' into s-dash-stdin 2018-04-14 14:17:51 -05:00
Björn Linse
aea079a25d channels: delay free so that libuv can cleanup handles
add test for a crash this caused
2018-04-12 18:22:47 +02:00
Jan Edmund Lazo
51f5cfc16e test: win: enable jobpid() tests
Use ping to test job detach
Use find.exe as an alternative to cat.exe
Use nvim_get_proc to check pid
2018-03-26 01:45:42 -04:00
Jan Edmund Lazo
ad6d577314 fixup: ping.exe works with cmd.exe pipe 2018-03-26 01:45:41 -04:00
Jan Edmund Lazo
e6ee06ee11 Revert "test/win: use cmd.exe for test"
This reverts commit ae409b5042.

This PR (#8120) defaults to cmd.exe for job_spec.lua
2018-03-26 01:45:41 -04:00
Jan Edmund Lazo
03e69a5d9c test: win: use find.exe /v "" as alternative cat - 2018-03-26 01:45:40 -04:00
Jan Edmund Lazo
3bd555f1e6 test: win: try stderr callback and slow output 2018-03-26 01:45:38 -04:00
Jan Edmund Lazo
cf4fbb6f04 test: win: use powershell for Start-Sleep only
cmd.exe (shell) is faster and more reliable than powershell (.NET frontend).
It's best for short and basic tests that don't require non-trivial scripting.
cmd.exe doesn't support sleep so use powershell's Start-Sleep as substitute.
2018-03-26 01:45:37 -04:00
Nimit Bhardwaj
8d64a2fb1d test: lua test for vim-patch:8.0.0184
2b7bc567b9
2018-03-24 23:06:09 +01:00
Justin M. Keyes
ae409b5042 test/win: use cmd.exe for test
Can revert this after #8120.
2018-03-18 17:15:06 +01:00
Justin M. Keyes
167898a517 test: jobstop() kills entire process tree
Test correctly fails before 8d90171f8b.
ref #6530
2018-03-18 17:03:05 +01:00
Justin M. Keyes
fd4021387e test: rename next_message() to next_msg() 2018-03-11 12:43:42 +01:00
Justin M. Keyes
2bf0869160 test: handle non-deterministic message cadence 2018-03-11 12:43:42 +01:00
Björn Linse
c57d315963
Merge pull request #8031 from bfredl/gotintstatus
jobwait: return -2 on interrupt even with timeout
2018-02-20 15:15:06 +01:00
Björn Linse
04fdbfe17d jobwait: return -2 on interrupt also with timeout 2018-02-20 12:32:23 +01:00
Jan Edmund Lazo
7fa69fb288 Resolve issues mentioned in PR review 2018-02-19 07:10:47 -05:00
Jan Edmund Lazo
3e19e18f4c win: enable job tests that use jobstart only
- echo "" does not hang in powershell
    - cmd.exe's echo command does not hang.
    - job tests default to powershell (WHY?)
- wait 5 seconds for powershell to create an empty file
    - powershell is slow
    - cannot reliably validate the id returned by jobstart via jobpid, jobstop
    - if using cmd.exe, waiting for a second should be enough
- remaining job tests are unreliable in Windows because any build can pass/fail
  for same conditions without changes, especially if the error is in stderr
2018-02-19 07:10:41 -05:00
Justin M. Keyes
e72ecdb7ca test/util: expect_msg_seq()
job_spec.lua on AppVeyor (Windows) often fails like this:

      FAILED  ] C:/projects/neovim/test/functional\core\job_spec.lua @ 72: jobs changes to given `cwd` directory
    C:/projects/neovim/test/functional\core\job_spec.lua:81: Expected objects to be the same.
    Passed in:
    (table) {
      [1] = 'notification'
      [2] = 'stdout'
     *[3] = {
        [1] = 0
       *[2] = {
          [1] = 'C:\projects\neovim\Xtest-tmpdir\nvimmSjq1S\0' } } }
    Expected:
    (table) {
      [1] = 'notification'
      [2] = 'stdout'
     *[3] = {
        [1] = 0
       *[2] = {
          [1] = 'C:\projects\neovim\Xtest-tmpdir\nvimmSjq1S\0'
         *[2] = '' } } }
    stack traceback:

Message chunking is non-deterministic, so we need to try different
variants.
2018-02-18 19:19:03 +01:00
George Zhao
499c9a1553 test/win: fix some environment assumptions #7912
fix #7909
fix #7910
2018-01-28 19:10:18 +01:00
Björn Linse
308dd53783 channel: check for existance before trying to set key
This avoids an error message in async context, where it is not safe.
2017-12-23 14:02:00 +01:00
ZyX
c49e22d396 Merge branch 'master' into s-dash-stdin 2017-12-03 16:49:30 +03:00
Björn Linse
e3c4c8a90e tests: mark flaky socket test pending for now 2017-11-27 11:43:24 +01:00
Björn Linse
91b856ccce channels: tests 2017-11-26 09:17:04 +01:00
Justin M. Keyes
54cac3033f test: startup_spec: cmd.exe escaping 2017-11-04 09:36:52 +01:00
Justin M. Keyes
68bef0a57d test: has("ttyin"), has("ttyout") 2017-11-04 09:36:52 +01:00
Josh Leeb-du Toit
9db42d4ce9 :cquit : take an error code argument #7336
closes #2699

ex_cmds.lua: use flags consistent with similar commands such as `cnext`.

upstream discussion:
"[patch] :qcuit can take exit code"
https://groups.google.com/d/msg/vim_dev/_PjyNbUKyRc/oPgr5_ZXc6AJ
2017-10-22 13:02:31 +02:00
Justin M. Keyes
6f7754dfa0 test: avoid extra clear() calls
also: various other cleanup
2017-10-02 01:46:16 +02:00
Ignas Anikevicius
2b133101cf win: vim_FullName(): force backslashes #7287
- Replace obvious cases of '/' literal with PATHSEP. (There are still
  some remaining cases that need closer inspection.)
- Fixup tests: ui/screen_basic

closes #7117
ref https://github.com/neovim/neovim/issues/2471#issuecomment-271193714
2017-10-02 00:48:30 +02:00
Drew Neil
ac52947838 Repair job_spec functional tests 2017-08-21 20:44:03 +01:00
Justin M. Keyes
92101947fe test: job_spec.lua: disable shada in test instance 2017-08-04 22:25:39 +02:00