Skip to content
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

Backport System.Job and System.Process.Job #513

Closed
wants to merge 7 commits into from
Closed

Conversation

lambdalisue
Copy link
Member

@lambdalisue lambdalisue commented May 20, 2017

from https://github.com/lambdalisue/vital-System-Job

ついでに Travis で Neovim のテストも走らせています。
現状は System.Job だけです。

@tyru
Copy link
Member

tyru commented May 20, 2017

https://github.com/lambdalisue/vital-System-Job は MIT ライセンスみたいですけど vital に入れるなら NYSL になると思いますが、大丈夫ですかね?

@lambdalisue
Copy link
Member Author

はい。そのつもりでライセンス部分消しました。

call extend(self._content, [leading . get(a:msg, 0, '')] + a:msg[1:])
endfunction

function! s:stream.on_stderr(job, msg, event) abort

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
EVL103: unused argument a:job

" Stream ---------------------------------------------------------------------
let s:stream = {}

function! s:stream.on_stdout(job, msg, event) abort

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
EVL103: unused argument a:event

" Stream ---------------------------------------------------------------------
let s:stream = {}

function! s:stream.on_stdout(job, msg, event) abort

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
EVL103: unused argument a:job

call s:_on_msg_cb(a:name, a:job, a:job.__channel, msg)
endif
sleep 1m
let status = ch_status(a:job.__channel, a:options)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
E118: Too many arguments for function: ch_status

\ 'timeout': 10000,
\ 'out_cb': function('s:_on_msg_cb', ['stdout', job]),
\ 'err_cb': function('s:_on_msg_cb', ['stderr', job]),
\ 'exit_cb': function('s:_on_exit_cb', [job]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
E118: Too many arguments for function: function

call extend(self._content, [leading . get(a:msg, 0, '')] + a:msg[1:])
endfunction

function! s:stream.on_stderr(job, msg, event) abort

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
EVL103: unused argument a:event

\ 'mode': 'raw',
\ 'timeout': 10000,
\ 'out_cb': function('s:_on_msg_cb', ['stdout', job]),
\ 'err_cb': function('s:_on_msg_cb', ['stderr', job]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
E118: Too many arguments for function: function

let job_options = {
\ 'mode': 'raw',
\ 'timeout': 10000,
\ 'out_cb': function('s:_on_msg_cb', ['stdout', job]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
E118: Too many arguments for function: function

endfunction

function! s:_read_channel_and_call_callback(job, name, options) abort
let status = ch_status(a:job.__channel, a:options)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
E118: Too many arguments for function: ch_status

INTRODUCTION *Vital.System.Job-introduction*

*Vital.System.Job* is a wrapper module of job feature which has introduced
from Vim 8 or Neovim.
Copy link
Member

@ujihisa ujihisa May 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to provide an abstract layer that works both for Vim 8 and Neovim at the same time とかみたいに両方イけることを強調するとなお良さそう

=============================================================================
USAGE *Vital.System.Job-usage*

The following code start "git status" and store its' stdout/stderr output in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/'//
s/start/starts/
s/store/stores/

"on_exit" A callback called when the process terminated.
The {msg} is an exit status.

Note that all attributes in the {options} is exposed to the job
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/is/are/

@lambdalisue lambdalisue changed the title WIP: Backport System.Job and System.Process.Job Backport System.Job and System.Process.Job May 20, 2017
@lambdalisue lambdalisue requested review from ujihisa, thinca and rhysd May 20, 2017 09:43
@lambdalisue
Copy link
Member Author

だいたいレビュー揃ってから修正開始します。
一応これ以後は最後の最後以外は --force しないのでクローンOKです

@ujihisa
Copy link
Member

ujihisa commented May 20, 2017

方針は超LGTM
明日手元で実際に使ってあれこれしてみよう

@tyru
Copy link
Member

tyru commented May 21, 2017

@haya14busa @thinca このモジュールって Vim 8 か NeoVim でしか動かないと思うのですが、そういうモジュールの場合、import() 時にエラーになる仕組みってないんでしたっけ?
例えばユーザの Vim が 7.x で import() した時に
Vim 8 or NeoVim is required みたいな例外を投げたい場合、s:_vital_created() で throw すればそのまま import() 時に上位に伝わったりしますかね?
あとそれが投げたい場合の正式な手順としてサポートすべきかという話も含めて相談したいです。

@tyru
Copy link
Member

tyru commented May 21, 2017

オフトピな話題ですみません。
必要ありそうなら別 issue 立ててそこで議論したい…

@ujihisa
Copy link
Member

ujihisa commented May 21, 2017

@haya14busa @thinca このモジュールって Vim 8 か NeoVim でしか動かないと思うのですが、そういうモジュールの場合、import() 時にエラーになる仕組みってないんでしたっけ?

現状import()時ではなく、is_available()などを明示的に呼び出して利用可能か確認するモジュールならある、という感じです (vimprocに依存してるConcurrentProcessなど)。あちらであの仕様にしたのは、「importはトップレベルでとにかく無条件に行って、プラギンの各関数でis_availableして、プラギンごとによしなに対処する」みたいなつくりが実用上便利だったからです。

今後この方針を変えるかどうか一度ちゃんと議論するのはよさそう。もちもん、それはこのpullreqとは別の独立したissueでだけど

@tyru
Copy link
Member

tyru commented May 21, 2017

@ujihisa なるほど…ありがとうございます。issue 作っちゃいました。 #515

.travis.yml Outdated
- ruby scripts/check-changelog.rb
- bash scripts/script.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

script.sh はファイル名が何をするスクリプトか分かるように改名したほうが良いかもです.


function! s:job.wait(...) abort
let timeout = get(a:000, 0, v:null)
if timeout is# v:null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ここは v:null を持ち出さなくても

if a:0 > 0
  return jobwait([self.__job], a:1)[0]
else
  return jobwait([self.__job])[0]
endif

で良いかもです

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

その場合 s:job.wait(v:null) と明示的に指定できなくなるので少し表現力が下がってしまいます。
例えば s:job.wait(...) を内部的に呼び出す別の関数が会った場合 v:null を渡してもOKという状況のほうが使い勝手が高いと思います。

let msg = ch_read(a:job.__channel, a:options)
call s:_on_msg_cb(a:name, a:job, a:job.__channel, msg)
endif
sleep 1m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なぜ 1m 待っているのかコメントがあると嬉しいかもです

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆗

" Start job and return a job instance
let job.__job = jobstart(a:args, job)
let job.__status = job.__job > 0 ? 'run' : 'dead'
let job.args = a:args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この args プロパティは後で使っていない気がします

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前口頭で説明しましたが、この args は後で参照できるように残してあります


function! s:is_supported(options) abort
if get(a:options, 'background') && (
\ s:Prelude.is_string(get(a:options, 'input')) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prelude は一応廃止じゃなかったでしたっけ?(CC: @ujihisa)もしそうなら上記の s:t_list みたいに自前でチェックしたほうが良いかもしれないです.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type もあるし、とりあえずこれはこのままで行きます〜

echomsg printf(
\ 'vital: System.Process.Job: %s',
\ cmdline
\)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ここは . で文字列結合で良い気も.

echomsg 'vital: System.Process.Job: ' . cmdline

@lambdalisue
Copy link
Member Author

やっと Travis 氏倒した……

再レビューお願い致します

endif
" Without sleep, Vim would hung
sleep 1m
let status = ch_status(a:job.__channel, a:options)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[vimlint] reported by reviewdog 🐶
E118: Too many arguments for function: ch_status

@lambdalisue
Copy link
Member Author

倒せてなかったorz

Backport System.Job and System.Process.Job from
https://github.com/lambdalisue/vital-System-Job

To fix travis for Neovim, the following are also performed

- Use 'trusty' instead to upgrade cmake newer
- Add requirements for build Neovim
- Fix test scripts
- Remove unnecessary flags to reduce dependencies
  - --enable-perlinterp
  - --enable-rubyinterp
@lambdalisue
Copy link
Member Author

lambdalisue commented Jul 1, 2017

drone で client9/misspell のビルドにコケてるけど beego/wetalk#32 っぽい?

[info] Pulling image plugins/drone-git:latest
Drone Git Plugin built from 43dcd64
$ git init
Initialized empty Git repository in /drone/src/github.com/vim-jp/vital.vim/.git/
$ git remote add origin https://github.com/vim-jp/vital.vim.git
$ git fetch --no-tags origin +refs/pull/513/merge:
From https://github.com/vim-jp/vital.vim
 * branch            refs/pull/513/merge -> FETCH_HEAD
$ git checkout -qf FETCH_HEAD
$ go get -d -v ./scripts
github.com/haya14busa/go-vimlparser (download)
$ go get -u github.com/client9/misspell/cmd/misspell
go build github.com/client9/misspell: /usr/lib/go/pkg/tool/linux_amd64/compile: signal: killed
[info] build failed (exit code 1)

@lambdalisue
Copy link
Member Author

@haya14busa ちょっと僕だと drone コケてるの直せないので確認していただけませんか?

@haya14busa
Copy link
Member

job restartしたら green になりました.が,これは根本的ソリューションではない...

スペック低すぎてリソース足りなくて misspell ビルドできないってケースなのかもしれないですね... っらぃ...

@rhysd
Copy link
Contributor

rhysd commented Jul 2, 2017

@haya14busa ビルドするのやめてバイナリ置いとくだけにします? misspell は割りと実装がゴリ押しなのでそのせいでビルドにメモリ食うのかも…

@lambdalisue
Copy link
Member Author

ビルドで落ちるの健康に悪い(ビルドで落ちたら嫌だからコミットしたくないとか)のでバイナリ置けるのであればそうして頂けると助かりますー

@k-takata
Copy link
Member

k-takata commented Jul 2, 2017

公式のnightly buildはどうでしょうか。
https://github.com/neovim/bot-ci#setting-up-integration-builds

@lambdalisue
Copy link
Member Author

お、misspell とは違いますが、確かに neovim のビルドこれ使った方が良いかもですね。週末詳しくみてみます

haya14busa added a commit that referenced this pull request Jul 5, 2017
Building misspell might use lots of resource and be killed.
#513 (comment)

ref: https://github.com/client9/misspell#install
haya14busa added a commit that referenced this pull request Jul 5, 2017
Building misspell might use lots of resource and be killed.
#513 (comment)

ref: https://github.com/client9/misspell#install
While non of code use rubyinterp. I simply removed it.
@lambdalisue
Copy link
Member Author

クソ面倒クセェ!!!

Wait a bit before job.status() is called
@lambdalisue
Copy link
Member Author

ちょっと思う所あるから一旦おろします。

@lambdalisue lambdalisue closed this Nov 4, 2017
@thinca thinca deleted the system-job branch December 17, 2017 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants