Skip to content

Commit

Permalink
Merge pull request #26 from JetBrains/issue-25
Browse files Browse the repository at this point in the history
#25 Support test metadata
  • Loading branch information
NikolayPianikov committed Dec 11, 2018
2 parents 69c68d9 + 9fd9b98 commit c902c67
Show file tree
Hide file tree
Showing 69 changed files with 365 additions and 244 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion TeamCity.ServiceMessages.Tests/Read/StringWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -75,5 +75,53 @@ public void TestStdOut()
{
DoTest(x => x.WriteStdOutput("outp4uz"), "##teamcity[testStdOut name='BadaBumBigBadaBum' out='outp4uz' tc:tags='tc:parseServiceMessagesInside']");
}

[Test]
public void TestWriteTextValue()
{
DoTest(x => x.WriteValue("strVal", "myVal"), "##teamcity[testMetadata testName='BadaBumBigBadaBum' value='strVal' name='myVal']");
}

[Test]
[TestCase(1.0d, "1")]
[TestCase(0.0d, "0")]
[TestCase(-1.0d, "-1")]
[TestCase(1.33d, "1.33")]
[TestCase(-1.33d, "-1.33")]
[TestCase(0.33d, "0.33")]
public void TestWriteNumber(double value, string expectedValueInMessage)
{
DoTest(x => x.WriteValue(value, "myVal"), "##teamcity[testMetadata testName='BadaBumBigBadaBum' type='number' value='" + expectedValueInMessage + "' name='myVal']");
}

[Test]
public void TestWriteLink()
{
DoTest(x => x.WriteLink("http://abc.com", "abc"), "##teamcity[testMetadata testName='BadaBumBigBadaBum' type='link' value='http://abc.com' name='abc']");
}

[Test]
public void TestWriteFile()
{
DoTest(x => x.WriteFile("abc.txt", "abc"), "##teamcity[testMetadata testName='BadaBumBigBadaBum' type='artifact' value='abc.txt' name='abc']");
}

[Test]
public void TestWriteFileWithoutDescription()
{
DoTest(x => x.WriteFile("abc.txt"), "##teamcity[testMetadata testName='BadaBumBigBadaBum' type='artifact' value='abc.txt']");
}

[Test]
public void TestWriteImage()
{
DoTest(x => x.WriteImage("abc.jpg", "abc"), "##teamcity[testMetadata testName='BadaBumBigBadaBum' type='image' value='abc.jpg' name='abc']");
}

[Test]
public void TestWriteImageWithoutDescription()
{
DoTest(x => x.WriteImage("abc.jpg"), "##teamcity[testMetadata testName='BadaBumBigBadaBum' type='image' value='abc.jpg']");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,11 +63,11 @@ private void DoTestImpl(Action<T> action, Func<string, string> replace, string[]
var actualText = "\r\n" + string.Join("\r\n", actual);
var expected = preprocess(string.Join("\r\n", golds));

if (actual.Count() != expected.Count())
if (actual.Length != expected.Length)
Assert.Fail("Incorrect number of messages. Was: " + actualText);

for (var i = 0; i < actual.Count(); i++)
Assert.AreEqual(actual[i], expected[i], "Message {0} does not match. Was: {1}", i, actualText);
Assert.AreEqual(expected[i], actual[i], "Message {0} does not match. Was: {1}", i, actualText);
}

protected class ToStringProcessor : IServiceMessageProcessor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 2 additions & 0 deletions TeamCity.ServiceMessages.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@
&lt;/Patterns&gt;</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AddImportsToDeepestScope/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
Expand Down
26 changes: 13 additions & 13 deletions TeamCity.ServiceMessages/Annotations.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -157,7 +157,7 @@ public ValueProviderAttribute([NotNull] string name)
/// <example><code>
/// void Foo(string param) {
/// if (param == null)
/// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
/// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.Parameter)]
Expand Down Expand Up @@ -188,8 +188,8 @@ internal sealed class InvokerParameterNameAttribute : Attribute { }
/// string _name;
///
/// public string Name {
/// get { return _name; }
/// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
/// get { return _name; }
/// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
/// }
/// }
/// </code>
Expand Down Expand Up @@ -310,11 +310,11 @@ public LocalizationRequiredAttribute(bool required)
///
/// class UsesNoEquality {
/// void Test() {
/// var ca1 = new NoEquality();
/// var ca2 = new NoEquality();
/// if (ca1 != null) { // OK
/// bool condition = ca1 == ca2; // Warning
/// }
/// var ca1 = new NoEquality();
/// var ca2 = new NoEquality();
/// if (ca1 != null) { // OK
/// bool condition = ca1 == ca2; // Warning
/// }
/// }
/// }
/// </code></example>
Expand Down Expand Up @@ -500,8 +500,8 @@ public MustUseReturnValueAttribute([NotNull] string justification)
/// [ProvidesContext] IBarService _barService = ...;
///
/// void ProcessNode(INode node) {
/// DoSomething(node, node.GetGlobalServices().Bar);
/// // ^ Warning: use value of '_barService' field
/// DoSomething(node, node.GetGlobalServices().Bar);
/// // ^ Warning: use value of '_barService' field
/// }
/// }
/// </code></example>
Expand Down Expand Up @@ -546,7 +546,7 @@ public PathReferenceAttribute([NotNull, PathReference] string basePath)
/// [SourceTemplate]
/// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; xs) {
/// foreach (var x in xs) {
/// //$ $END$
/// //$ $END$
/// }
/// }
/// </code>
Expand All @@ -569,7 +569,7 @@ internal sealed class SourceTemplateAttribute : Attribute { }
/// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
/// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; collection) {
/// foreach (var item in collection) {
/// //$ $END$
/// //$ $END$
/// }
/// }
/// </code>
Expand Down
14 changes: 7 additions & 7 deletions TeamCity.ServiceMessages/IServiceMessage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,31 +19,31 @@ namespace JetBrains.TeamCity.ServiceMessages
using System.Collections.Generic;

/// <summary>
/// Object representation of TeamCity service message
/// Object representation of TeamCity service message
/// </summary>
public interface IServiceMessage
{
/// <summary>
/// Service message name, i.e. messageName in ##teamcity[messageName 'ddd'].
/// Service message name, i.e. messageName in ##teamcity[messageName 'ddd'].
/// </summary>
[NotNull]
string Name { get; }

/// <summary>
/// For one-value service messages returns value, i.e. 'aaa' for ##teamcity[message 'aaa']
/// or <code>null</code> otherwise, i.e. ##teamcity[message aa='aaa']
/// For one-value service messages returns value, i.e. 'aaa' for ##teamcity[message 'aaa']
/// or <code>null</code> otherwise, i.e. ##teamcity[message aa='aaa']
/// </summary>
[CanBeNull]
string DefaultValue { get; }

/// <summary>
/// Emptry for one-value service messages, i.e. ##teamcity[message 'aaa'], returns all keys otherwise
/// Emptry for one-value service messages, i.e. ##teamcity[message 'aaa'], returns all keys otherwise
/// </summary>
[NotNull]
IEnumerable<string> Keys { get; }

/// <summary>
/// Return a value for keys or <code>null</code>
/// Return a value for keys or <code>null</code>
/// </summary>
/// <param name="key">Key to check for value</param>
/// <returns>value of available or <code>null</code></returns>
Expand Down
8 changes: 4 additions & 4 deletions TeamCity.ServiceMessages/Read/IServiceMessageParser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,20 +20,20 @@ namespace JetBrains.TeamCity.ServiceMessages.Read
using System.IO;

/// <summary>
/// Provides service messages parsing from stream
/// Provides service messages parsing from stream
/// </summary>
public interface IServiceMessageParser
{
/// <summary>
/// Lazy parses service messages from string
/// Lazy parses service messages from string
/// </summary>
/// <param name="text">text to parse</param>
/// <returns>enumerable of service messages</returns>
[NotNull]
IEnumerable<IServiceMessage> ParseServiceMessages([NotNull] string text);

/// <summary>
/// Reads stream parsing service messages from it.
/// Reads stream parsing service messages from it.
/// </summary>
/// <param name="reader">stream to parse. Stream will not be closed</param>
/// <returns>Iterator of service messages</returns>
Expand Down
2 changes: 1 addition & 1 deletion TeamCity.ServiceMessages/Read/ServiceMessage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2017 JetBrains s.r.o.
* Copyright 2007-2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit c902c67

Please sign in to comment.