Skip to content

Commit

Permalink
Merge branch 'main' into 1595-detect-repo-when-using-relative-urls
Browse files Browse the repository at this point in the history
  • Loading branch information
alnlarsen committed Jun 19, 2024
2 parents 960af54 + 0c96c5e commit 0860972
Show file tree
Hide file tree
Showing 47 changed files with 2,642 additions and 24,433 deletions.
35 changes: 20 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,21 @@ jobs:
with:
name: doc-api-html
path: API
- name: Pages Cache
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v4
name: Setup NPM
with:
node-version: 14
- name: Install
run: npm install
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: "doc/package-lock.json"
- name: Install dependencies
run: npm ci
working-directory: doc
- name: Build
run: npm run build
# This is needed because the router wants to serve index.html as the default page
- name: Rename Index
run: mv Readme.md index.md
working-directory: doc
- name: Build with VitePress
run: npm run docs:build
working-directory: doc
- name: Copy API
run: cp -r API public/api
Expand All @@ -164,6 +163,12 @@ jobs:
deploy_key: ${{ secrets.PAGES_DEPLOY_TOKEN }}
publish_branch: main
external_repository: opentap/opentap.github.io
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: pages
retention-days: 5
path: public

Build-Linux:
runs-on: ubuntu-latest
Expand Down
34 changes: 20 additions & 14 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,21 @@ jobs:
with:
name: doc-api-html
path: API
- name: Pages Cache
uses: actions/cache@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v4
name: Setup NPM
with:
node-version: 14
- name: Install
run: npm install
node-version: 20
cache: npm
cache-dependency-path: "doc/package-lock.json"
- name: Install dependencies
run: npm ci
working-directory: doc
# This is needed because the router wants to serve index.html as the default page
- name: Rename Index
run: mv Readme.md index.md
working-directory: doc
- name: Build
run: npm run build
- name: Build with VitePress
run: npm run docs:build
working-directory: doc
- name: Copy API
run: cp -r API public/api
Expand All @@ -111,3 +110,10 @@ jobs:
deploy_key: ${{ secrets.PAGES_DEPLOY_TOKEN }}
publish_branch: main
external_repository: opentap/opentap.github.io
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: pages
retention-days: 5
path: public

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ TestResults/
nuget/build/payload
node_modules/
/public/
doc/.vitepress/dist/
doc/.vitepress/cache/
.DS_Store

# Temp files from git merges:
*.orig
Expand All @@ -18,4 +21,4 @@ TestResult.xml
LinuxInstall/package

#ignore Rider files
*.idea/
*.idea/
2 changes: 1 addition & 1 deletion .gitversion
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This is the version number that will be used. Prerelease numbers are calculated by
# counting git commits since the last change in this value.

version = 9.24.3
version = 9.25.0

# A version is determined to be a "beta" prerelease if it originates from the default branch
# The default branch is the first branch that matches the following regular expession.
Expand Down
6 changes: 5 additions & 1 deletion BasicSteps/ParallelStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public void Run2()
{
try
{
RunChildStep(step);
var run = RunChildStep(step);
while(run.SuggestedNextStep == step.Id)
{
run = RunChildStep(step);
}
}
catch
{
Expand Down
6 changes: 3 additions & 3 deletions Engine.UnitTests/AssemblyDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public void ConflictingAssemblyVersionTest()
Assert.AreEqual(Version.Parse("3.0.1.0"), globAsm.Version);

var newtonsoftAsm = s.Assemblies.FirstOrDefault(a => a.Name.Contains("Newtonsoft.Json"));
Assert.AreEqual(SemanticVersion.Parse("12.0.3"), SemanticVersion.Parse(newtonsoftAsm.SemanticVersion.ToString(3)));
Assert.AreEqual(SemanticVersion.Parse("13.0.3"), SemanticVersion.Parse(newtonsoftAsm.SemanticVersion.ToString(3)));
// The newtonsoft package is actually version 12.0.0.3, but the assembly version is 12.0.0.0 for some reason.
// This was changed in 9.18.2 due to a regression, but it has been so for a long long time.
Assert.AreEqual(Version.Parse("12.0.0.0"), newtonsoftAsm.Version);
Assert.AreEqual(Version.Parse("13.0.0.0"), newtonsoftAsm.Version);
}

[Test]
Expand All @@ -63,4 +63,4 @@ public void OpenTapVersionTest()
}

}
}
}
43 changes: 42 additions & 1 deletion Engine.UnitTests/TestPlanCompositeRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,55 @@ public void ShortTimeSpanTest()
var s = new[] { "10 ms", "1 ms", "100 us", "10 μs", "1 μs", "1 ns", "0 s" };

for (int i = 0; i < v.Length; i++)
{
{
var s1 = ShortTimeSpan.FromSeconds(v[i]);
var s2 = ShortTimeSpan.FromString(s[i]);
StringAssert.AreEqualIgnoringCase(s1.ToString(), s2.ToString());

}
}

[Test]
public void LongTimeSpanTest()
{
var seconds = new TimeSpan[]
{
new TimeSpan(1, 0, 0, 0),
new TimeSpan(0, 23, 30, 0) ,
new TimeSpan(23, 12, 22, 0),
new TimeSpan(1, 0, 5, 0),
new TimeSpan(0, 5, 0, 3),
new TimeSpan(3, 0, 21, 10),
new TimeSpan(999, 23 ,59, 59),
new TimeSpan(1, 0,0, 59),
new TimeSpan(0, 0,0, 1),
new TimeSpan(0,0, 0,0),
new TimeSpan(0,0, 1,59),
new TimeSpan(0,0,0,59)
};
var expectedTimeSpan = new[]
{
"1 d",
"23 h 30 m",
"23 d 12 h 22 m",
"1 d 5 m",
"5 h 3 s" ,
"3 d 21 m 10 s",
"999 d 23 h 59 m 59 s",
"1 d 59 s",
"1.00 s",
"0.00 s",
"1 m 59 s",
"59.0 s"
};

for (int i = 0; i < seconds.Length; i++)
{
var actualTimeSpan = ShortTimeSpan.LongTimeSpanFormat(seconds[i]).Trim();
StringAssert.AreEqualIgnoringCase(expectedTimeSpan[i], actualTimeSpan);
}
}


[Test, Retry(3)]
public void RunCompositeFollowedByRun()
Expand Down
41 changes: 39 additions & 2 deletions Engine.UnitTests/TestPlanTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public void PrintTestPlanRunSummaryTest()
Assert.IsTrue(summaryLines[4].Contains("1 artifacts registered"));
Assert.IsTrue(summaryLines[5].Contains(testFileName));
Assert.IsTrue(summaryLines[5].EndsWith("[1.5 kB]"));

}

[Test]
Expand Down Expand Up @@ -628,7 +627,7 @@ public override void OnTestStepRunStart(TestStepRun stepRun)
[Test]
public void RepeatChildStepsFailure()
{

var plan = new TestPlan();
var repeat = new RepeatRunChildSteps { Repeats = 10 };
var repeat2 = new RepeatRunChildSteps { Repeats = 10 };
Expand All @@ -638,8 +637,46 @@ public void RepeatChildStepsFailure()
var run = plan.Execute(new IResultListener[] { new SlowResultListener() });
Assert.AreEqual(Verdict.NotSet, run.Verdict);
}
/// <summary>
/// Tests that if the SuggestedNextStep is set to the current ID, thn the testStep will be repeated.
/// </summary>
[Test]
public void SuggestedNextStepTest()
{
using (Session.Create(SessionOptions.OverlayComponentSettings))
{
var plan = new TestPlan();
var parallelStep = new ParallelStep();
var nextStepRepeater = new SuggestedNextStepRepeater();
nextStepRepeater.RepeatCount = 10;
parallelStep.ChildTestSteps.Add(nextStepRepeater);
plan.ChildTestSteps.Add(parallelStep);
PlanRunCollectorListener planRunListener = new PlanRunCollectorListener();
ResultSettings.Current.Add(planRunListener);

var planRun = plan.Execute();

var stepRuns = planRunListener.StepRuns;

//We compare repeatcount + 1 as the parallelStep is also counted in StepsRun.
Assert.AreEqual(nextStepRepeater.RepeatCount + 1, stepRuns.Count);
}
}

public class SuggestedNextStepRepeater : TestStep
{
public int RepeatCount { get; set; }
public int Repeats { get; set; }

public override void Run()
{
if(Repeats < RepeatCount -1)
{
this.StepRun.SuggestedNextStep = this.Id;
Repeats++;
}
}
}

public class VerifyTestStep : TestStep
{
Expand Down
9 changes: 4 additions & 5 deletions Engine/TestPlanRunSummaryListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,11 @@ static void printSummary(IDictionary<Guid, TestStepRunData> stepRuns, TestStepRu
int indentcnt = stepRunIndent(stepRuns, run);
string indent = new String(' ', indentcnt * 2);
string inverseIndent = new String(' ', maxIndent * 2 - indentcnt * 2);

var (timeString, unit) = ShortTimeSpan.FromSeconds(run.Duration.TotalSeconds).ToStringParts();

string v = run.Verdict == Verdict.NotSet ? "" : run.Verdict.ToString();
var name = run.TestStepName;
// this prints something like this: '12:42:16.302 Summary Delay 106 ms'
summaryLog.Info($"{indent} {name,-43} {inverseIndent}{timeString,5:0} {unit,-4}{v,-7}");
summaryLog.Info($"{indent} {name,-43} {inverseIndent}{ShortTimeSpan.LongTimeSpanFormat(run.Duration)} {v,-7}");

int idx2 = 0;
foreach (TestStepRunData run2 in lookup[run.Id])
Expand Down Expand Up @@ -245,11 +244,11 @@ public void PrintSummary()

if (!hasOtherVerdict)
{
summaryLog.Info(formatSummary($" Test plan completed successfully in {ShortTimeSpan.FromSeconds(planRun.Duration.TotalSeconds).ToString(),6} "));
summaryLog.Info(formatSummary($" Test plan completed successfully in {ShortTimeSpan.LongTimeSpanFormat(planRun.Duration)} "));
}
else
{
summaryLog.Info(formatSummary(string.Format(" Test plan completed with verdict {1} in {0,6} ", ShortTimeSpan.FromSeconds(planRun.Duration.TotalSeconds).ToString(), planRun.Verdict)));
summaryLog.Info(formatSummary(string.Format(" Test plan completed with verdict {1} in {0,6} ", ShortTimeSpan.LongTimeSpanFormat(planRun.Duration), planRun.Verdict)));
}
}

Expand Down
1 change: 0 additions & 1 deletion Engine/TestStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,6 @@ public static TestStepRun RunChildStep(this ITestStep step, ITestStep childStep,
if(run.Verdict == Verdict.Error && throwOnBreak)
run.ThrowDueToBreakConditions();
}

return run;
}

Expand Down
2 changes: 1 addition & 1 deletion Package/Tap.Package.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="LibGit2Sharp" Version="0.27.0.0-preview-0175" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Mono.Cecil" Version="0.10.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NuGet.Client" Version="4.2.0" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
Expand Down
45 changes: 45 additions & 0 deletions Shared/ShortTimeSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// file, you can obtain one at http://mozilla.org/MPL/2.0/.
using System.Globalization;
using System;
using System.Xml.Linq;

namespace OpenTap
{
Expand All @@ -12,6 +13,7 @@ namespace OpenTap
/// </summary>
struct ShortTimeSpan
{

public enum UnitKind{
Seconds,
Milliseconds,
Expand Down Expand Up @@ -58,6 +60,49 @@ public static ShortTimeSpan FromSeconds(double seconds)
return new ShortTimeSpan { unit = unit, Value = Math.Round(s, 3) };
}

/// <summary>
/// For formating of timespans longer than 1 minute like "1 d 1 h 14m" instead of "90840 s"
/// </summary>
/// <param name="timeSpan"></param>
/// <returns></returns>
public static string LongTimeSpanFormat(TimeSpan timeSpan)
{
string result = "";
if (timeSpan.TotalMinutes < 1)
{
var (timeString, unit) = FromSeconds(timeSpan.TotalSeconds).ToStringParts();

return FormatTimeStringParts(timeString, unit);
}
if (timeSpan.Days > 0)
{
result += $"{timeSpan.Days} d ";

}
if (timeSpan.Hours > 0)
{
result += $"{timeSpan.Hours} h ";
}

if (timeSpan.Minutes > 0)
{
result += $"{timeSpan.Minutes} m ";
}

if (timeSpan.Seconds > 0)
{
result += $"{timeSpan.Seconds} s ";
}

return result.Trim();
}

private static string FormatTimeStringParts(string timeString, string unit)
{
var formattedString = $"{timeString,5:0} {unit,-4}";
return formattedString;
}

public static ShortTimeSpan FromString(string str)
{
str = str.Trim();
Expand Down
Loading

0 comments on commit 0860972

Please sign in to comment.