Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions mod/completion/function/analysis.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ z.completion.function._candidates() {
local prefix=$1
local function_names=("${z_completion_function_names[@]}")

z.int.is.zero ${#function_names[@]} && return 1

local candidates=()
for function_name in $function_names; do
if z.str.start_with "$function_name" "z." &&
Expand Down
4 changes: 2 additions & 2 deletions mod/completion/process.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ z.completion.enable() {
z.completion.is._interactive || return 0

z.completion.cache.build._names
z.completion.compdef._ignore_private || return 1
z.completion.compdef._ignore_private
z.completion.compdef._register || return 1
autoload -Uz add-zsh-hook
add-zsh-hook zshexit z.completion.cache._cancel || return 1
add-zsh-hook zshexit z.completion.cache._cancel
z.completion.cache._cancel

z.job.run \
Expand Down
2 changes: 1 addition & 1 deletion mod/job/analysis.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ z.job.status() {
z.arg.named id "$@" && local id=$REPLY
z.is.null "$id" && return 1

z.job.file._path id=$id name=status || return 1
z.job.file._path id=$id name=status
local status_file=$REPLY
z.file.exists "$status_file" || return 1

Expand Down
2 changes: 1 addition & 1 deletion mod/job/file/analysis.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ z.job.file._path() {
z.is.null "$id" && return 1
z.is.null "$name" && return 1

z.job.file._dir id=$id || return 1
z.job.file._dir id=$id
z.return "$REPLY/$name"
}
2 changes: 1 addition & 1 deletion mod/job/process.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ z.job.run() {
name="$name" \
command="$command" \
on_success="$on_success" \
on_failure="$on_failure" || return 1
on_failure="$on_failure"
local -a prepared=("${REPLY[@]}")
local id=$prepared[1]
local dir=$prepared[2]
Expand Down
7 changes: 2 additions & 5 deletions mod/job/run/process.zsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# prepare a job directory
# prepare a job directory after argument validation
#
# $name: job name
# $command: child function name
# $on_success?: parent success callback function name
# $on_failure?: parent failure callback function name
# REPLY: job id and job directory
# return: 0|1
# return: null
#
# example:
# z.job.run._prepare name=example command=z.example.build
Expand All @@ -15,9 +15,6 @@ z.job.run._prepare() {
z.arg.named on_success "$@" && local on_success=$REPLY
z.arg.named on_failure "$@" && local on_failure=$REPLY

z.is.null "$name" && return 1
z.is.null "$command" && return 1

z.job.file._jobs && local jobs_dir=$REPLY
z.dir.exists "$jobs_dir" || z.dir.make path="$jobs_dir"

Expand Down
2 changes: 1 addition & 1 deletion mod/wtproxy/config/analysis.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# example:
# z.wtproxy._config
z.wtproxy._config() {
z.wtproxy._config.values || return 1
z.wtproxy._config.values
local -A config=("${(@)REPLY}")

z.wtproxy._config.file.default_project || {
Expand Down
2 changes: 1 addition & 1 deletion mod/wtproxy/port/analysis.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ z.wtproxy._port.proxies() {

z.wtproxy._port.keys.from_config config
for port_key in ${(@)REPLY}; do
z.wtproxy._port.worktree.index $port_key || return 1
z.wtproxy._port.worktree.index $port_key
local port_index=$REPLY
z.wtproxy._port.proxy.key $port_index
local config_key=$REPLY
Expand Down
3 changes: 1 addition & 2 deletions mod/wtproxy/proxy/is/operator.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ z.wtproxy._proxy.is.pid() {
z.is.null "$pid" && return 1
z.io.null kill -0 "$pid" || return 1

local command_line
command_line=$(ps -p "$pid" -o command= 2>/dev/null) || return 1
local command_line=$(ps -p "$pid" -o command= 2>/dev/null)
z.str.includes "$command_line" "z.wtproxy.start._serve"
}
15 changes: 15 additions & 0 deletions test/mod/completion/cache/process_test.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ z.t.describe "z.completion.cache._cancel"; {
}
}

z.t.context "jobの取消に失敗した場合"; {
z.t.it "補完側のIDを破棄して成功する"; {
local z_completion_cache_job_id=cache-job
z.t.mock name="z.job.status" behavior="z.return running"
z.t.mock name="z.job.cancel" behavior="return 1"

z.completion.cache._cancel
local result_code=$?
local remaining_id=$z_completion_cache_job_id

z.t.expect "$result_code" 0
z.t.expect.is.null "$remaining_id"
}
}

z.t.context "補完jobがない場合"; {
z.t.it "他のjobに触れず成功する"; {
local z_completion_cache_job_id=""
Expand Down
18 changes: 12 additions & 6 deletions test/mod/completion/process_test.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,23 @@ z.t.describe "z.completion.enable"; {
}

z.t.context "private除外設定に失敗した場合"; {
z.t.it "jobを起動しない"; {
z.t.it "補完登録とcache jobの起動を続ける"; {
local z_completion_cache_job_id=""
local -a zshexit_functions=()
local -a completion_calls=()
z.t.mock name="z.completion.is._interactive" behavior="return 0"
z.t.mock name="z.completion.compdef._ignore_private" behavior="return 1"
z.t.mock name="z.completion.compdef._register" behavior="return 0"
z.t.mock name="z.job.run" behavior="z.return job-id"
z.t.mock name="z.completion.compdef._register" behavior='completion_calls+=(register); return 0'
z.t.mock name="z.job.run" behavior='completion_calls+=(job); z.return job-id'

z.completion.enable
local result_code=$?
local result_reply=$REPLY

z.t.expect.status.is.false skip_unmock=true
z.t.mock.result name="z.job.run"
z.t.expect.reply ""
z.t.expect "$result_code" 0 skip_unmock=true
z.t.expect "$result_reply" job-id skip_unmock=true
z.t.expect "$completion_calls" "register job" skip_unmock=true
z.t.expect "$zshexit_functions" z.completion.cache._cancel
}
}

Expand Down
11 changes: 11 additions & 0 deletions test/mod/wtproxy/proxy/is/operator_test.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,15 @@ z.t.describe "z.wtproxy._proxy.is.pid"; {
z.t.expect.status.is.false
}
}

z.t.context "pid確認後にprocessが終了した場合"; {
z.t.it "commandを取得できないためfalseを返す"; {
z.t.mock name="kill" behavior="return 0"
z.t.mock name="ps" behavior="return 1"

z.wtproxy._proxy.is.pid 12345

z.t.expect.status.is.false
}
}
}
Loading