-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
! lib_compiled: Add initial support for remote repositories
TODO: handle errors, add support for multiple repositories
- Loading branch information
1 parent
c715cf3
commit 8d09a88
Showing
6 changed files
with
432 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
param([Parameter(Mandatory)]$RemoteRepoDir) | ||
|
||
$env:POG_DEBUG = "1"; Import-Module Pog | ||
|
||
cd $RemoteRepoDir | ||
|
||
rm -Recurse * | ||
|
||
$Packages = [array][Pog.InternalState]::Repository.Enumerate() | ||
|
||
$VersionMap = [ordered]@{} | ||
$Packages | % { | ||
$VersionMap[$_.PackageName] = @($_.EnumerateVersions() | % ToString) | ||
} | ||
# not really html, but whatever | ||
$VersionMap | ConvertTo-Json -Depth 100 -Compress > index.html | ||
|
||
$TmpPackage = New-PogImportedPackage _zip_export | ||
try { | ||
$Packages | % { | ||
$null = mkdir $_.PackageName | ||
$_.Enumerate() | % { | ||
$_.ImportTo($TmpPackage) | ||
Compress-Archive "$($TmpPackage.Path)\*" ".\$($_.PackageName)\$($_.Version).zip" | ||
echo $_.Path | ||
} | ||
} | ||
} finally { | ||
rm -Force -Recurse $TmpPackage.Path | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Pog.Utils; | ||
using Xunit; | ||
|
||
namespace Pog.Tests.Utils; | ||
|
||
public class TimedLazyTests { | ||
[Fact] | ||
public void TestCaching() { | ||
TestClass.Reset(); | ||
var lazy = new TimedLazy<TestClass>(TimeSpan.FromMilliseconds(100), () => new TestClass()); | ||
|
||
Assert.Equal(0, lazy.Value.Index); | ||
Assert.Equal(0, lazy.Value.Index); | ||
Assert.Equal(0, lazy.Value.Index); | ||
|
||
Thread.Sleep(105); | ||
|
||
Assert.Equal(1, lazy.Value.Index); | ||
Assert.Equal(1, lazy.Value.Index); | ||
Assert.Equal(1, lazy.Value.Index); | ||
|
||
lazy.Invalidate(); | ||
Assert.Equal(2, lazy.Value.Index); | ||
} | ||
|
||
// in case TimedLazy is ever switched to a struct, this test validates that it's not copied where it shouldn't be | ||
[Fact] | ||
public void TestCachingWithWrapper() { | ||
TestClass.Reset(); | ||
var wrapper = new Wrapper(); | ||
|
||
Assert.Equal(0, wrapper.Value.Index); | ||
Assert.Equal(0, wrapper.Value.Index); | ||
Assert.Equal(0, wrapper.Value.Index); | ||
|
||
Thread.Sleep(105); | ||
|
||
Assert.Equal(1, wrapper.Value.Index); | ||
Assert.Equal(1, wrapper.Value.Index); | ||
Assert.Equal(1, wrapper.Value.Index); | ||
} | ||
|
||
private class Wrapper { | ||
private readonly TimedLazy<TestClass> _lazy = new(TimeSpan.FromMilliseconds(100), () => new TestClass()); | ||
internal TestClass Value => _lazy.Value; | ||
} | ||
|
||
private class TestClass { | ||
private static int _counter = 0; | ||
public readonly int Index = _counter++; | ||
|
||
internal static void Reset() { | ||
_counter = 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.