Skip to content

Commit

Permalink
azdevops: xamarin#79.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Apr 5, 2019
1 parent 5142fae commit 9bc35c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions tests/sampletester/GitHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,30 @@ public static string [] GetProjects (string user, string repo, string hash)
}).ToArray ();
}

public static string CloneRepository (string user, string repo, string hash, bool clean = true)
public static string CloneRepository (string org, string repo, string hash, bool clean = true)
{
var repo_dir = Path.Combine (Configuration.SampleRootDirectory, repo);

if (!Directory.Exists (repo_dir)) {
Console.WriteLine ($"Cloning https://github.com/{org}/{repo} (hash: {hash})");
Directory.CreateDirectory (repo_dir);
Assert.AreEqual (0, ExecutionHelper.Execute ("git", new string [] { "init" }, working_directory: repo_dir, timeout: TimeSpan.FromSeconds (10)), "git init");
Assert.AreEqual (0, ExecutionHelper.Execute ("git", new string [] { "remote", "add", "origin", $"https://github.com/{user}/{repo}" }, working_directory: repo_dir, timeout: TimeSpan.FromSeconds (10)), "git remote add");
Assert.AreEqual (0, ExecutionHelper.Execute ("git", new string [] { "remote", "add", "origin", $"https://github.com/{org}/{repo}" }, working_directory: repo_dir, timeout: TimeSpan.FromSeconds (10)), "git remote add");
Assert.AreEqual (0, ExecutionHelper.Execute ("git", new string [] { "fetch" }, working_directory: repo_dir, timeout: TimeSpan.FromMinutes (10)), "git fetch");
Assert.AreEqual (0, ExecutionHelper.Execute ("git", new string [] { "checkout", "-b", "temporary-sample-testing-branch", hash }, working_directory: repo_dir, timeout: TimeSpan.FromMinutes (1)), "git checkout");
Assert.AreEqual (0, ExecutionHelper.Execute ("git", new string [] { "submodule", "update", "--init", "--recursive" }, working_directory: repo_dir, timeout: TimeSpan.FromMinutes (10)), "git submodule update");

ExecutionHelper.Execute ("git", new string [] { "log", "--oneline", "--pretty=* @%h %s", "HEAD", "^origin/master" }, out var output1, working_directory: repo_dir, timeout: TimeSpan.FromSeconds (10));
if (output1.Length > 0) {
Console.WriteLine ("Commits not in origin/master:");
Console.WriteLine (output1.ToString ().TrimEnd ('\n'));
}
ExecutionHelper.Execute ("git", new string [] { "log", "--oneline", "--pretty=* %h %s", "origin/master", "^HEAD" }, out var output2, working_directory: repo_dir, timeout: TimeSpan.FromSeconds (10));
if (output2.Length > 0) {
Console.WriteLine ("Commits in origin/master not being tested:");
Console.WriteLine (output2.ToString ().TrimEnd ('\n'));
}

} else if (clean) {
Assert.AreEqual (0, ExecutionHelper.Execute ("git", new string [] { "reset", "--hard", hash }, working_directory: repo_dir, timeout: TimeSpan.FromMinutes (1)), "git checkout");
CleanRepository (repo_dir);
Expand Down
2 changes: 1 addition & 1 deletion tests/sampletester/Samples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class MacIosSampleTester : SampleTester {
const string ORG = "xamarin";
const string REPO = "mac-ios-samples";
const string CATEGORY = "maciossamples"; // categories can't contain dashes
const string HASH = "9c3fd48abdd80c320db17f286eaf43073161ccff";
const string HASH = "2ab4faf9254cecdf5766af573e508f9ac8691663";

static Dictionary<string, SampleTest> test_data = new Dictionary<string, SampleTest> {
// Build solution instead of csproj
Expand Down

0 comments on commit 9bc35c1

Please sign in to comment.