Skip to content

Commit

Permalink
run: fix confusing error message for tt run
Browse files Browse the repository at this point in the history
If tarantool executable is not found, `tt run` prints
"open : no such file or directory" error, which is
confusing. Make the error message more clear.

Closes #966
  • Loading branch information
psergee authored and oleg-jukovec committed Oct 7, 2024
1 parent 062a172 commit 21384b6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/running/base_instance.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package running

import (
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -150,6 +151,9 @@ func (inst *baseInstance) StopWithSignal(waitTimeout time.Duration, usedSignal o
func (inst *baseInstance) Run(opts RunOpts) error {
f, err := inst.integrityCtx.Repository.Read(inst.tarantoolPath)
if err != nil {
if os.IsNotExist(err) {
return errors.New("tarantool executable is not found")
}
return err
}
f.Close()
Expand Down
24 changes: 24 additions & 0 deletions test/integration/run/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import shutil
import subprocess

import pytest

from utils import config_name


def test_run_base_functionality(tt_cmd, tmpdir_with_cfg):
# Copy the test application to the "run" directory.
Expand Down Expand Up @@ -128,3 +132,23 @@ def test_run_from_input(tt_cmd, tmpdir_with_cfg):
run_output = process.stdout.readlines()
assert re.search(r"a\s+b\s+c", run_output[0])
assert re.search(r"a\s+b\s+c", run_output[0])


@pytest.mark.notarantool
@pytest.mark.skipif(shutil.which("tarantool") is not None, reason="tarantool found in PATH")
def test_run_without_tarantool(tt_cmd, tmp_path):
with open(tmp_path / config_name, "w") as f:
f.write('env:')

run_cmd = [tt_cmd, "run", "--version"]
tt_process = subprocess.Popen(
run_cmd,
cwd=tmp_path,
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
text=True
)

tt_process.wait(3)
assert tt_process.returncode != 0
assert "tarantool executable is not found" in tt_process.stdout.read()

0 comments on commit 21384b6

Please sign in to comment.