public override void SetUp() { base.SetUp(); toLoad = new AList<WindowCacheGetTest.TestObject>(); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream( JGitTestUtil.GetTestResourceFile("all_packed_objects.txt")), Constants.CHARSET)); try { string line; while ((line = br.ReadLine()) != null) { string[] parts = line.Split(" {1,}"); WindowCacheGetTest.TestObject o = new WindowCacheGetTest.TestObject(this); o.id = ObjectId.FromString(parts[0]); o.SetType(parts[1]); // parts[2] is the inflate size // parts[3] is the size-in-pack // parts[4] is the offset in the pack toLoad.AddItem(o); } } finally { br.Close(); } NUnit.Framework.Assert.AreEqual(96, toLoad.Count); }
// expected /// <exception cref="System.IO.IOException"></exception> private int CountPicks() { int count = 0; FilePath todoFile = new FilePath(db.Directory, "rebase-merge/git-rebase-todo"); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream( todoFile), "UTF-8")); try { string line = br.ReadLine(); while (line != null) { string actionToken = Sharpen.Runtime.Substring(line, 0, line.IndexOf(' ')); RebaseCommand.Action action = null; try { action = RebaseCommand.Action.Parse(actionToken); } catch (Exception) { } // ignore if (action != null) { count++; } line = br.ReadLine(); } return count; } finally { br.Close(); } }
private string GetLinesStartingWith(string prefix) { BufferedReader r = new BufferedReader(new StringReader(output)); string line = null; string rv = string.Empty; try { while ((line = r.ReadLine()) != null) { if (line.StartsWith(prefix)) { if (rv.Length > 0) { rv += "\n"; } rv += line; } } return rv; } catch (IOException) { throw new Exception("Can't happen."); } }
/// <exception cref="System.IO.IOException"></exception> private void ReadPackedRefsImpl(IDictionary<string, Ref> avail, BufferedReader br ) { Ref last = null; bool peeled = false; for (; ; ) { string line = br.ReadLine(); if (line == null) { break; } if (line[0] == '#') { if (line.StartsWith(RefDirectory.PACKED_REFS_HEADER)) { line = Sharpen.Runtime.Substring(line, RefDirectory.PACKED_REFS_HEADER.Length); peeled = line.Contains(RefDirectory.PACKED_REFS_PEELED); } continue; } if (line[0] == '^') { if (last == null) { throw new TransportException(JGitText.Get().peeledLineBeforeRef); } ObjectId id = ObjectId.FromString(Sharpen.Runtime.Substring(line, 1)); last = new ObjectIdRef.PeeledTag(RefStorage.PACKED, last.GetName(), last.GetObjectId (), id); avail.Put(last.GetName(), last); continue; } int sp = line.IndexOf(' '); if (sp < 0) { throw new TransportException(MessageFormat.Format(JGitText.Get().unrecognizedRef, line)); } ObjectId id_1 = ObjectId.FromString(Sharpen.Runtime.Substring(line, 0, sp)); string name = Sharpen.Runtime.Substring(line, sp + 1); if (peeled) { last = new ObjectIdRef.PeeledNonTag(RefStorage.PACKED, name, id_1); } else { last = new ObjectIdRef.Unpeeled(RefStorage.PACKED, name, id_1); } avail.Put(last.GetName(), last); } }
/// <exception cref="System.Exception"></exception> public static void Run(ShellContextFactory shellContextFactory, FilePath jsFile, ShellTest.Parameters parameters, ShellTest.Status status) { Global global = new Global(); MemoryStream @out = new MemoryStream(); TextWriter p = new TextWriter(@out); global.SetOut(p); global.SetErr(p); global.DefineFunctionProperties(new string[] { "options" }, typeof(ShellTest), ScriptableObject.DONTENUM | ScriptableObject.PERMANENT | ScriptableObject.READONLY); // test suite expects keywords to be disallowed as identifiers shellContextFactory.SetAllowReservedKeywords(false); ShellTest.TestState testState = new ShellTest.TestState(); if (jsFile.GetName().EndsWith("-n.js")) { status.SetNegative(); } Exception[] thrown = new Exception[] { null }; Sharpen.Thread t = new Sharpen.Thread(new _Runnable_274(shellContextFactory, thrown, testState, status, jsFile, global), jsFile.GetPath()); t.SetDaemon(true); t.Start(); t.Join(parameters.GetTimeoutMilliseconds()); lock (testState) { if (!testState.finished) { CallStop(t); status.TimedOut(); } } int expectedExitCode = 0; p.Flush(); status.OutputWas(Sharpen.Runtime.GetStringForBytes(@out.ToArray())); BufferedReader r = new BufferedReader(new StreamReader(new MemoryStream(@out.ToArray()))); string failures = string.Empty; for (; ; ) { string s = r.ReadLine(); if (s == null) { break; } if (s.IndexOf("FAILED!") != -1) { failures += s + '\n'; } int expex = s.IndexOf("EXPECT EXIT CODE "); if (expex != -1) { expectedExitCode = s[expex + "EXPECT EXIT CODE ".Length] - '0'; } } if (thrown[0] != null) { status.Threw(thrown[0]); } status.ExitCodesWere(expectedExitCode, testState.exitCode); if (failures != string.Empty) { status.Failed(failures); } }
/// <exception cref="System.Exception"></exception> private IDictionary<string, DirCacheCGitCompatabilityTest.CGitLsTreeRecord> ReadLsTree () { LinkedHashMap<string, DirCacheCGitCompatabilityTest.CGitLsTreeRecord> r = new LinkedHashMap <string, DirCacheCGitCompatabilityTest.CGitLsTreeRecord>(); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream( PathOf("gitgit.lstree")), "UTF-8")); try { string line; while ((line = br.ReadLine()) != null) { DirCacheCGitCompatabilityTest.CGitLsTreeRecord cr = new DirCacheCGitCompatabilityTest.CGitLsTreeRecord (line); r.Put(cr.path, cr); } } finally { br.Close(); } return r; }
internal SimpleShellConsole(Stream @in, TextWriter ps, Encoding cs) { this.@in = @in; this.@out = new PrintWriter(ps); this.reader = new BufferedReader(new StreamReader(@in, cs)); }