Skip to content

Commit 21384b6

Browse files
psergeeoleg-jukovec
authored andcommitted
run: fix confusing error message for tt run
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
1 parent 062a172 commit 21384b6

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

cli/running/base_instance.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package running
22

33
import (
4+
"errors"
45
"fmt"
56
"io"
67
"os"
@@ -150,6 +151,9 @@ func (inst *baseInstance) StopWithSignal(waitTimeout time.Duration, usedSignal o
150151
func (inst *baseInstance) Run(opts RunOpts) error {
151152
f, err := inst.integrityCtx.Repository.Read(inst.tarantoolPath)
152153
if err != nil {
154+
if os.IsNotExist(err) {
155+
return errors.New("tarantool executable is not found")
156+
}
153157
return err
154158
}
155159
f.Close()

test/integration/run/test_run.py

+24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import shutil
44
import subprocess
55

6+
import pytest
7+
8+
from utils import config_name
9+
610

711
def test_run_base_functionality(tt_cmd, tmpdir_with_cfg):
812
# Copy the test application to the "run" directory.
@@ -128,3 +132,23 @@ def test_run_from_input(tt_cmd, tmpdir_with_cfg):
128132
run_output = process.stdout.readlines()
129133
assert re.search(r"a\s+b\s+c", run_output[0])
130134
assert re.search(r"a\s+b\s+c", run_output[0])
135+
136+
137+
@pytest.mark.notarantool
138+
@pytest.mark.skipif(shutil.which("tarantool") is not None, reason="tarantool found in PATH")
139+
def test_run_without_tarantool(tt_cmd, tmp_path):
140+
with open(tmp_path / config_name, "w") as f:
141+
f.write('env:')
142+
143+
run_cmd = [tt_cmd, "run", "--version"]
144+
tt_process = subprocess.Popen(
145+
run_cmd,
146+
cwd=tmp_path,
147+
stderr=subprocess.STDOUT,
148+
stdout=subprocess.PIPE,
149+
text=True
150+
)
151+
152+
tt_process.wait(3)
153+
assert tt_process.returncode != 0
154+
assert "tarantool executable is not found" in tt_process.stdout.read()

0 commit comments

Comments
 (0)