mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-01-14 22:18:43 +00:00
Test server for linux
This commit is contained in:
parent
db2643fc6e
commit
3594e508e4
@ -3,6 +3,9 @@ dist: trusty
|
|||||||
sudo: required
|
sudo: required
|
||||||
mono: none
|
mono: none
|
||||||
dotnet: 1.0.0-preview2-003131
|
dotnet: 1.0.0-preview2-003131
|
||||||
|
befor_install:
|
||||||
|
- sudo apt-get update -qq
|
||||||
|
- sudo apt-get install -y mpd
|
||||||
script:
|
script:
|
||||||
- dotnet restore
|
- dotnet restore
|
||||||
- dotnet build **/project.json
|
- dotnet build **/project.json
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace LibMpcTest
|
namespace LibMpcTest
|
||||||
{
|
{
|
||||||
@ -8,20 +9,17 @@ namespace LibMpcTest
|
|||||||
{
|
{
|
||||||
public MpdServerTest()
|
public MpdServerTest()
|
||||||
{
|
{
|
||||||
var serverPath = Path.Combine(AppContext.BaseDirectory, "Server");
|
MpdConf.Create(Path.Combine(AppContext.BaseDirectory, "Server"));
|
||||||
|
|
||||||
MpdConf.Create(serverPath);
|
var server = GetServer();
|
||||||
|
|
||||||
var mpdExePath = Path.Combine(serverPath, "mpd.exe");
|
|
||||||
var mpdConfPath = Path.Combine(serverPath, "mpd.conf");
|
|
||||||
|
|
||||||
Process = new Process
|
Process = new Process
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo
|
StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = mpdExePath,
|
FileName = server.FileName,
|
||||||
WorkingDirectory = serverPath,
|
WorkingDirectory = server.WorkingDirectory,
|
||||||
Arguments = string.Join(" ", mpdConfPath, "-v"),
|
Arguments = server.Arguments,
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
@ -34,6 +32,21 @@ namespace LibMpcTest
|
|||||||
LogError = Process.StandardError.ReadToEnd();
|
LogError = Process.StandardError.ReadToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Server GetServer()
|
||||||
|
{
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
return Server.Linux;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
return Server.Windows;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotSupportedException("OS not supported");
|
||||||
|
}
|
||||||
|
|
||||||
public Process Process { get; }
|
public Process Process { get; }
|
||||||
public string LogError { get; }
|
public string LogError { get; }
|
||||||
public string LogOutput { get; }
|
public string LogOutput { get; }
|
||||||
@ -43,5 +56,29 @@ namespace LibMpcTest
|
|||||||
Process?.Kill();
|
Process?.Kill();
|
||||||
Process?.Dispose();
|
Process?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class Server
|
||||||
|
{
|
||||||
|
public static Server Linux = new Server(
|
||||||
|
fileName: "/usr/bin/mpd",
|
||||||
|
workingDirectory: "/usr/bin/",
|
||||||
|
arguments: string.Join(" ", Path.Combine(AppContext.BaseDirectory, "Server", "mpd.conf"), "-v"));
|
||||||
|
|
||||||
|
public static Server Windows = new Server(
|
||||||
|
fileName: Path.Combine(AppContext.BaseDirectory, "Server", "mpd.exe"),
|
||||||
|
workingDirectory: Path.Combine(AppContext.BaseDirectory, "Server"),
|
||||||
|
arguments: string.Join(" ", Path.Combine(AppContext.BaseDirectory, "Server", "mpd.conf"), "-v"));
|
||||||
|
|
||||||
|
private Server(string fileName, string workingDirectory, string arguments)
|
||||||
|
{
|
||||||
|
FileName = fileName;
|
||||||
|
WorkingDirectory = workingDirectory;
|
||||||
|
Arguments = arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FileName { get; }
|
||||||
|
public string WorkingDirectory { get; }
|
||||||
|
public string Arguments { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user