• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

UiPath / uipathcli / 13943577226

19 Mar 2025 09:50AM UTC coverage: 90.112% (-0.4%) from 90.483%
13943577226

push

github

web-flow
Merge pull request #165 from UiPath/feature/test-run-command

Add run command to execute tests on UiPath Orchestrator

581 of 690 new or added lines in 17 files covered. (84.2%)

2 existing lines in 1 file now uncovered.

5860 of 6503 relevant lines covered (90.11%)

1.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.0
/plugin/studio/uipcli.go
1
package studio
2

3
import (
4
        "bufio"
5
        "fmt"
6
        "io"
7
        "path/filepath"
8
        "runtime"
9
        "strings"
10
        "sync"
11

12
        "github.com/UiPath/uipathcli/log"
13
        "github.com/UiPath/uipathcli/plugin"
14
        "github.com/UiPath/uipathcli/utils/process"
15
)
16

17
const uipcliCrossPlatformVersion = "24.12.9111.31003"
18
const uipcliCrossPlatformUrl = "https://uipath.pkgs.visualstudio.com/Public.Feeds/_apis/packaging/feeds/1c781268-d43d-45ab-9dfc-0151a1c740b7/nuget/packages/UiPath.CLI/versions/" + uipcliCrossPlatformVersion + "/content"
19

20
const uipcliWindowsVersion = "24.12.9111.31003"
21
const uipcliWindowsUrl = "https://uipath.pkgs.visualstudio.com/Public.Feeds/_apis/packaging/feeds/1c781268-d43d-45ab-9dfc-0151a1c740b7/nuget/packages/UiPath.CLI.Windows/versions/" + uipcliWindowsVersion + "/content"
22

23
const dotnetLinuxX64Url = "https://aka.ms/dotnet/8.0/dotnet-runtime-linux-x64.tar.gz"
24
const dotnetMacOsX64Url = "https://aka.ms/dotnet/8.0/dotnet-runtime-osx-x64.tar.gz"
25
const dotnetWindowsX64Url = "https://aka.ms/dotnet/8.0/dotnet-runtime-win-x64.zip"
26

27
const dotnetLinuxArm64Url = "https://aka.ms/dotnet/8.0/dotnet-runtime-linux-arm64.tar.gz"
28
const dotnetMacOsArm64Url = "https://aka.ms/dotnet/8.0/dotnet-runtime-osx-arm64.tar.gz"
29
const dotnetWindowsArm64Url = "https://aka.ms/dotnet/8.0/dotnet-runtime-win-arm64.zip"
30

31
type uipcli struct {
32
        Exec   process.ExecProcess
33
        Logger log.Logger
34
        path   string
35
        args   []string
36
}
37

38
func (c *uipcli) Initialize(targetFramework TargetFramework) error {
1✔
39
        uipcliPath, err := c.getUipcliPath(targetFramework)
1✔
40
        if err != nil {
1✔
41
                return err
×
42
        }
×
43
        c.path = uipcliPath
1✔
44

1✔
45
        if filepath.Ext(c.path) == ".dll" {
2✔
46
                dotnetPath, err := c.getDotnetPath()
1✔
47
                if err != nil {
1✔
48
                        return err
×
49
                }
×
50
                c.path = dotnetPath
1✔
51
                c.args = []string{uipcliPath}
1✔
52
        }
53
        return nil
1✔
54
}
55

56
func (c uipcli) Execute(args ...string) (process.ExecCmd, error) {
1✔
57
        args = append(c.args, args...)
1✔
58
        cmd := c.Exec.Command(c.path, args...)
1✔
59
        return cmd, nil
1✔
60
}
1✔
61

62
func (c uipcli) ExecuteAndWait(args ...string) (int, string, error) {
1✔
63
        cmd, err := c.Execute(args...)
1✔
64
        if err != nil {
1✔
NEW
65
                return 1, "", err
×
NEW
66
        }
×
67
        stdout, err := cmd.StdoutPipe()
1✔
68
        if err != nil {
1✔
NEW
69
                return 1, "", fmt.Errorf("Could not run command: %v", err)
×
NEW
70
        }
×
71
        defer stdout.Close()
1✔
72
        stderr, err := cmd.StderrPipe()
1✔
73
        if err != nil {
1✔
NEW
74
                return 1, "", fmt.Errorf("Could not run command: %v", err)
×
NEW
75
        }
×
76
        defer stderr.Close()
1✔
77
        err = cmd.Start()
1✔
78
        if err != nil {
1✔
NEW
79
                return 1, "", fmt.Errorf("Could not run command: %v", err)
×
NEW
80
        }
×
81

82
        stderrOutputBuilder := new(strings.Builder)
1✔
83
        stderrReader := io.TeeReader(stderr, stderrOutputBuilder)
1✔
84

1✔
85
        var wg sync.WaitGroup
1✔
86
        wg.Add(3)
1✔
87
        go c.readOutput(stdout, &wg)
1✔
88
        go c.readOutput(stderrReader, &wg)
1✔
89
        go c.wait(cmd, &wg)
1✔
90
        wg.Wait()
1✔
91

1✔
92
        return cmd.ExitCode(), stderrOutputBuilder.String(), nil
1✔
93
}
94

95
func (c uipcli) wait(cmd process.ExecCmd, wg *sync.WaitGroup) {
1✔
96
        defer wg.Done()
1✔
97
        _ = cmd.Wait()
1✔
98
}
1✔
99

100
func (c uipcli) readOutput(output io.Reader, wg *sync.WaitGroup) {
1✔
101
        defer wg.Done()
1✔
102
        scanner := bufio.NewScanner(output)
1✔
103
        scanner.Split(bufio.ScanRunes)
1✔
104
        for scanner.Scan() {
2✔
105
                c.Logger.Log(scanner.Text())
1✔
106
        }
1✔
107
}
108

109
func (c uipcli) getUipcliPath(targetFramework TargetFramework) (string, error) {
1✔
110
        externalPlugin := plugin.NewExternalPlugin(c.Logger)
1✔
111
        name := "uipcli"
1✔
112
        url := uipcliCrossPlatformUrl
1✔
113
        executable := "tools/uipcli.dll"
1✔
114
        if targetFramework.IsWindowsOnly() {
1✔
115
                name = "uipcli-win"
×
116
                url = uipcliWindowsUrl
×
117
                executable = "tools/uipcli.exe"
×
118
        }
×
119
        return externalPlugin.GetTool(name, url, plugin.ArchiveTypeZip, executable)
1✔
120
}
121

122
func (c uipcli) getDotnetPath() (string, error) {
1✔
123
        externalPlugin := plugin.NewExternalPlugin(c.Logger)
1✔
124
        name := fmt.Sprintf("dotnet8-%s-%s", runtime.GOOS, runtime.GOARCH)
1✔
125
        url, archiveType, executable := c.dotnetUrl()
1✔
126
        return externalPlugin.GetTool(name, url, archiveType, executable)
1✔
127
}
1✔
128

129
func (c uipcli) dotnetUrl() (string, plugin.ArchiveType, string) {
1✔
130
        if c.isArm() {
1✔
131
                switch runtime.GOOS {
×
132
                case "windows":
×
133
                        return dotnetWindowsArm64Url, plugin.ArchiveTypeZip, "dotnet.exe"
×
134
                case "darwin":
×
135
                        return dotnetMacOsArm64Url, plugin.ArchiveTypeTarGz, "dotnet"
×
136
                default:
×
137
                        return dotnetLinuxArm64Url, plugin.ArchiveTypeTarGz, "dotnet"
×
138
                }
139
        }
140
        switch runtime.GOOS {
1✔
141
        case "windows":
×
142
                return dotnetWindowsX64Url, plugin.ArchiveTypeZip, "dotnet.exe"
×
143
        case "darwin":
×
144
                return dotnetMacOsX64Url, plugin.ArchiveTypeTarGz, "dotnet"
×
145
        default:
1✔
146
                return dotnetLinuxX64Url, plugin.ArchiveTypeTarGz, "dotnet"
1✔
147
        }
148
}
149

150
func (c uipcli) isArm() bool {
1✔
151
        return strings.HasPrefix(strings.ToLower(runtime.GOARCH), "arm")
1✔
152
}
1✔
153

154
func newUipcli(exec process.ExecProcess, logger log.Logger) *uipcli {
1✔
155
        return &uipcli{exec, logger, "", []string{}}
1✔
156
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc