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

trace2: add child start and exit events #1131

Merged
Merged
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 @@ -24,7 +24,6 @@ public TesterWindow()
#if DEBUG
this.AttachDevTools();
#endif

if (PlatformUtils.IsWindows())
{
_environment = new WindowsEnvironment(new WindowsFileSystem());
Expand Down
11 changes: 10 additions & 1 deletion src/shared/Atlassian.Bitbucket.UI.Avalonia/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ private static void AppMain(object o)
{
ldennington marked this conversation as resolved.
Show resolved Hide resolved
string[] args = (string[]) o;

using (var context = new CommandContext(args))
// Set the session id (sid) for the helper process, to be
// used when TRACE2 tracing is enabled.
SidManager.CreateSid();
using (var context = new CommandContext())
using (var app = new HelperApplication(context))
{
// Initialize TRACE2 system
context.Trace2.Initialize(DateTimeOffset.UtcNow);

// Write the start and version events
context.Trace2.Start(context.ApplicationPath, args);

app.RegisterCommand(new CredentialsCommandImpl(context));

int exitCode = app.RunAsync(args)
Expand Down
55 changes: 37 additions & 18 deletions src/shared/Core.Tests/GitConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public void GitProcess_GetConfiguration_ReturnsConfiguration()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath);
var config = git.GetConfiguration();
Assert.NotNull(config);
}
Expand All @@ -71,7 +72,8 @@ public void GitConfiguration_Enumerate_CallbackReturnsTrue_InvokesCallbackForEac
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

var actualVisitedEntries = new List<(string name, string value)>();
Expand Down Expand Up @@ -109,7 +111,8 @@ public void GitConfiguration_Enumerate_CallbackReturnsFalse_InvokesCallbackForEa
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

var actualVisitedEntries = new List<(string name, string value)>();
Expand Down Expand Up @@ -139,7 +142,9 @@ public void GitConfiguration_TryGet_Name_Exists_ReturnsTrueOutString()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();

var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

bool result = config.TryGet("user.name", false, out string value);
Expand All @@ -156,7 +161,8 @@ public void GitConfiguration_TryGet_Name_DoesNotExists_ReturnsFalse()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

string randomName = $"{Guid.NewGuid():N}.{Guid.NewGuid():N}";
Expand All @@ -175,7 +181,8 @@ public void GitConfiguration_TryGet_IsPath_True_ReturnsCanonicalPath()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

bool result = config.TryGet("example.path", true, out string value);
Expand All @@ -193,7 +200,8 @@ public void GitConfiguration_TryGet_IsPath_False_ReturnsRawConfig()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

bool result = config.TryGet("example.path", false, out string value);
Expand All @@ -211,7 +219,8 @@ public void GitConfiguration_TryGet_BoolType_ReturnsCanonicalBool()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

bool result = config.TryGet(GitConfigurationLevel.Local, GitConfigurationType.Bool,
Expand All @@ -230,7 +239,8 @@ public void GitConfiguration_TryGet_BoolWithoutType_ReturnsRawConfig()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

bool result = config.TryGet(GitConfigurationLevel.Local, GitConfigurationType.Raw,
Expand All @@ -249,7 +259,8 @@ public void GitConfiguration_Get_Name_Exists_ReturnsString()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

string value = config.Get("user.name");
Expand All @@ -265,7 +276,8 @@ public void GitConfiguration_Get_Name_DoesNotExists_ThrowsException()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

string randomName = $"{Guid.NewGuid():N}.{Guid.NewGuid():N}";
Expand All @@ -280,7 +292,8 @@ public void GitConfiguration_Set_Local_SetsLocalConfig()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

config.Set(GitConfigurationLevel.Local, "core.foobar", "foo123");
Expand All @@ -298,7 +311,8 @@ public void GitConfiguration_Set_All_ThrowsException()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

Assert.Throws<InvalidOperationException>(() => config.Set(GitConfigurationLevel.All, "core.foobar", "test123"));
Expand All @@ -317,7 +331,8 @@ public void GitConfiguration_Unset_Global_UnsetsGlobalConfig()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

config.Unset(GitConfigurationLevel.Global, "core.foobar");
Expand Down Expand Up @@ -348,7 +363,8 @@ public void GitConfiguration_Unset_Local_UnsetsLocalConfig()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

config.Unset(GitConfigurationLevel.Local, "core.foobar");
Expand All @@ -374,7 +390,8 @@ public void GitConfiguration_Unset_All_ThrowsException()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

Assert.Throws<InvalidOperationException>(() => config.Unset(GitConfigurationLevel.All, "core.foobar"));
Expand All @@ -391,7 +408,8 @@ public void GitConfiguration_UnsetAll_UnsetsAllConfig()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

config.UnsetAll(GitConfigurationLevel.Local, "core.foobar", "foo*");
Expand All @@ -409,7 +427,8 @@ public void GitConfiguration_UnsetAll_All_ThrowsException()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, repoPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

Assert.Throws<InvalidOperationException>(() => config.UnsetAll(GitConfigurationLevel.All, "core.foobar", Constants.RegexPatterns.Any));
Expand Down
30 changes: 20 additions & 10 deletions src/shared/Core.Tests/GitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public void Git_GetCurrentRepository_NoLocalRepo_ReturnsNull()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, Path.GetTempPath());
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, Path.GetTempPath());

string actual = git.GetCurrentRepository();

Expand All @@ -29,7 +30,8 @@ public void Git_GetCurrentRepository_LocalRepo_ReturnsNotNull()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, workDirPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, workDirPath);

string actual = git.GetCurrentRepository();

Expand All @@ -42,7 +44,8 @@ public void Git_GetRemotes_NoLocalRepo_ReturnsEmpty()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, Path.GetTempPath());
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, Path.GetTempPath());

GitRemote[] remotes = git.GetRemotes().ToArray();

Expand All @@ -57,7 +60,8 @@ public void Git_GetRemotes_NoRemotes_ReturnsEmpty()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var git = new GitProcess(trace, env, gitPath, workDirPath);
var processManager = new TestProcessManager();
var git = new GitProcess(trace, processManager, gitPath, workDirPath);

GitRemote[] remotes = git.GetRemotes().ToArray();

Expand All @@ -75,8 +79,9 @@ public void Git_GetRemotes_OneRemote_ReturnsRemote()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var processManager = new TestProcessManager();

var git = new GitProcess(trace, env, gitPath, workDirPath);
var git = new GitProcess(trace, processManager, gitPath, workDirPath);
GitRemote[] remotes = git.GetRemotes().ToArray();

Assert.Single(remotes);
Expand All @@ -96,8 +101,9 @@ public void Git_GetRemotes_OneRemoteFetchAndPull_ReturnsRemote()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var processManager = new TestProcessManager();

var git = new GitProcess(trace, env, gitPath, workDirPath);
var git = new GitProcess(trace, processManager, gitPath, workDirPath);
GitRemote[] remotes = git.GetRemotes().ToArray();

Assert.Single(remotes);
Expand All @@ -119,8 +125,9 @@ public void Git_GetRemotes_NonHttpRemote_ReturnsRemote(string url)
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var processManager = new TestProcessManager();

var git = new GitProcess(trace, env, gitPath, workDirPath);
var git = new GitProcess(trace, processManager, gitPath, workDirPath);
GitRemote[] remotes = git.GetRemotes().ToArray();

Assert.Single(remotes);
Expand All @@ -144,8 +151,9 @@ public void Git_GetRemotes_MultipleRemotes_ReturnsAllRemotes()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var processManager = new TestProcessManager();

var git = new GitProcess(trace, env, gitPath, workDirPath);
var git = new GitProcess(trace, processManager, gitPath, workDirPath);
GitRemote[] remotes = git.GetRemotes().ToArray();

Assert.Equal(3, remotes.Length);
Expand All @@ -168,8 +176,9 @@ public void Git_GetRemotes_RemoteNoFetchOnlyPull_ReturnsRemote()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var processManager = new TestProcessManager();

var git = new GitProcess(trace, env, gitPath, workDirPath);
var git = new GitProcess(trace, processManager, gitPath, workDirPath);
GitRemote[] remotes = git.GetRemotes().ToArray();

Assert.Single(remotes);
Expand All @@ -183,8 +192,9 @@ public void Git_Version_ReturnsVersion()
string gitPath = GetGitPath();
var trace = new NullTrace();
var env = new TestEnvironment();
var processManager = new TestProcessManager();

var git = new GitProcess(trace, env, gitPath, Path.GetTempPath());
var git = new GitProcess(trace, processManager, gitPath, Path.GetTempPath());
GitVersion version = git.Version;

Assert.NotEqual(new GitVersion(), version);
Expand Down
Loading