Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link to correct Linux binary #45

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ namespace BrowserStack_Unit_Tests
public class BrowserStackTunnelTests
{
static readonly OperatingSystem os = Environment.OSVersion;
static readonly string homepath = os.Platform.ToString() == "Unix" ?
static readonly string homepath = os.Platform == PlatformID.Unix ?
Environment.GetFolderPath(Environment.SpecialFolder.Personal) :
Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
static readonly string binaryName = os.Platform.ToString() == "Unix" ? "BrowserStackLocal-darwin-x64" : "BrowserStackLocal.exe";
static readonly string binaryName =
os.Platform == PlatformID.Unix ? "BrowserStackLocal-linux-x64" : os.Platform == PlatformID.MacOSX ? "BrowserStackLocal-darwin-x64" : "BrowserStackLocal.exe";
private TunnelClass tunnel;
[TestMethod]
public void TestInitialState()
Expand Down
23 changes: 15 additions & 8 deletions BrowserStackLocal/BrowserStackLocal/BrowserStackTunnel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ public enum LocalState { Idle, Connecting, Connected, Error, Disconnected };

public class BrowserStackTunnel : IDisposable
{
static readonly string binaryName = isDarwin() ? "BrowserStackLocal-darwin-x64" : "BrowserStackLocal.exe";
static readonly string downloadURL = isDarwin() ?
"https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal-darwin-x64" :
"https://bstack-local-prod.s3.amazonaws.com/BrowserStackLocal.exe";
static readonly string homepath = isDarwin() ?
private static readonly string baseDownloadUrl = "https://bstack-local-prod.s3.amazonaws.com/";
private static readonly string binaryName =
IsLinux() ? "BrowserStackLocal-linux-x64" : IsDarwin() ? "BrowserStackLocal-darwin-x64" : "BrowserStackLocal.exe";

private static readonly string downloadURL = baseDownloadUrl + binaryName;
static readonly string homepath = IsDarwin() || IsLinux() ?
Environment.GetFolderPath(Environment.SpecialFolder.Personal) :
Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%");
public static readonly string[] basePaths = new string[] {
Expand All @@ -37,10 +38,16 @@ public class BrowserStackTunnel : IDisposable

Process process = null;

static Boolean isDarwin()
private static bool IsDarwin()
{
OperatingSystem os = Environment.OSVersion;
return os.Platform == PlatformID.MacOSX;
}

private static bool IsLinux()
{
OperatingSystem os = Environment.OSVersion;
return os.Platform.ToString() == "Unix";
return os.Platform == PlatformID.Unix;
}

public virtual void addBinaryPath(string binaryAbsolute)
Expand Down Expand Up @@ -79,7 +86,7 @@ public virtual void fallbackPaths()

public void modifyBinaryPermission()
{
if (isDarwin())
if (IsDarwin())
{
try
{
Expand Down