diff --git a/tests/sampletester/Configuration.cs b/tests/sampletester/Configuration.cs index e170384c9ed5..b5fdc81a4706 100644 --- a/tests/sampletester/Configuration.cs +++ b/tests/sampletester/Configuration.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using System.Reflection; diff --git a/tests/sampletester/GitHub.cs b/tests/sampletester/GitHub.cs index 30202c0246de..a4888c73a637 100644 --- a/tests/sampletester/GitHub.cs +++ b/tests/sampletester/GitHub.cs @@ -2,73 +2,19 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Net; -using System.Runtime.Serialization.Json; -using System.Xml; using NUnit.Framework; using Xamarin.Tests; public static class GitHub { - static WebClient CreateClient () - { - var client = new WebClient (); - client.Headers.Add (HttpRequestHeader.UserAgent, "xamarin"); - var xharness_github_token_file = Environment.GetEnvironmentVariable ("XHARNESS_GITHUB_TOKEN_FILE"); - if (!string.IsNullOrEmpty (xharness_github_token_file) && File.Exists (xharness_github_token_file)) - client.Headers.Add (HttpRequestHeader.Authorization, File.ReadAllText (xharness_github_token_file)); - return client; - } - - static string[] GetFiles (string user, string repo) - { - var fn = Path.Combine (Configuration.SampleRootDirectory, $"{repo}.filelist"); - if (File.Exists (fn)) - return File.ReadAllLines (fn); - Directory.CreateDirectory (Path.GetDirectoryName (fn)); - - using (var client = CreateClient ()) { - byte [] data; - try { - data = client.DownloadData ($"https://api.github.com/repos/{user}/{repo}/git/trees/master?recursive=1"); - } catch (WebException we) { - string rsp = we.Message; - try { - foreach (var header in we.Response.Headers.AllKeys) - rsp += $"\n{header}={we.Response.Headers [header]}"; - using (var webreader = new StreamReader (we.Response.GetResponseStream ())) - rsp += "\n" + webreader.ReadToEnd (); - } catch { - } - - return new string [] { $"Failed to load {user}/{repo}: {rsp}" }; - } - var reader = JsonReaderWriterFactory.CreateJsonReader (data, new XmlDictionaryReaderQuotas ()); - var doc = new XmlDocument (); - doc.Load (reader); - var rv = new List (); - foreach (XmlNode node in doc.SelectNodes ("/root/tree/item/path")) { - rv.Add (node.InnerText); - } - - File.WriteAllLines (fn, rv.ToArray ()); - return rv.ToArray (); - } - - } - - public static string [] GetProjects (string user, string repo, bool clone) + public static string [] GetProjects (string user, string repo) { IEnumerable files; - if (clone) { - var dir = CloneRepository (user, repo); - files = Directory.GetFiles (dir, "*.*", SearchOption.AllDirectories); - files = files.Select ((v) => v.Substring (dir.Length).TrimStart ('/')); - } else { - files = GetFiles (user, repo); - } + var dir = CloneRepository (user, repo); + files = Directory.GetFiles (dir, "*.*", SearchOption.AllDirectories); + files = files.Select ((v) => v.Substring (dir.Length).TrimStart ('/')); return files .Where ((v) => { diff --git a/tests/sampletester/MacSampleTester.cs b/tests/sampletester/MacSampleTester.cs index d39ebba774b7..3221bc026fe5 100644 --- a/tests/sampletester/MacSampleTester.cs +++ b/tests/sampletester/MacSampleTester.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; + using NUnit.Framework; namespace Samples { diff --git a/tests/sampletester/PrebuiltAppTester.cs b/tests/sampletester/PrebuiltAppTester.cs index 17f0bae917da..1791c0746417 100644 --- a/tests/sampletester/PrebuiltAppTester.cs +++ b/tests/sampletester/PrebuiltAppTester.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; + using NUnit.Framework; namespace Samples { diff --git a/tests/sampletester/SampleTester.cs b/tests/sampletester/SampleTester.cs index de735d1160ca..5259f6bd107c 100644 --- a/tests/sampletester/SampleTester.cs +++ b/tests/sampletester/SampleTester.cs @@ -1,13 +1,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.IO; -using System.Net; -using System.Runtime.Serialization.Json; -using System.Text; -using System.Threading; -using System.Xml; using NUnit.Framework; @@ -153,7 +147,7 @@ public void BuildSample ([ValueSource ("GetSampleData")] SampleTestData sampleTe protected static ProjectInfo [] GetExecutableProjects (string repo) { if (!projects.TryGetValue (repo, out var rv)) { - var project_paths = GitHub.GetProjects ("xamarin", repo, true); + var project_paths = GitHub.GetProjects ("xamarin", repo); // We can filter out project we don't care about. rv = project_paths. diff --git a/tests/sampletester/XamarinFormsSampleTester.cs b/tests/sampletester/XamarinFormsSampleTester.cs index 563ad76c11b4..462fff625c23 100644 --- a/tests/sampletester/XamarinFormsSampleTester.cs +++ b/tests/sampletester/XamarinFormsSampleTester.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; + using NUnit.Framework; namespace Samples {