2
* ALR - Any Linux Repository
3
* Copyright (C) 2024 Евгений Храмов
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
28
"plemya-x.ru/alr/internal/shutils/handlers"
29
"mvdan.cc/sh/v3/interp"
30
"mvdan.cc/sh/v3/syntax"
33
func TestNopExec(t *testing.T) {
34
ctx := context.Background()
36
fl, err := syntax.NewParser().Parse(strings.NewReader(`/bin/echo test`), "alr.sh")
38
t.Fatalf("Expected no error, got %s", err)
41
buf := &bytes.Buffer{}
42
runner, err := interp.New(
43
interp.ExecHandler(handlers.NopExec),
44
interp.StdIO(os.Stdin, buf, buf),
47
t.Fatalf("Expected no error, got %s", err)
50
err = runner.Run(ctx, fl)
52
t.Fatalf("Expected no error, got %s", err)
55
if buf.String() != "" {
56
t.Fatalf("Expected empty string, got %#v", buf.String())