Downloads:
500
Downloads of v 1.0:
500
Last Update:
07 Jul 2016
Package Maintainer(s):
Software Author(s):
- Chantisnake
Tags:
ctest admin chocolatey- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
ctest
- 1
- 2
- 3
1.0 | Updated: 07 Jul 2016
- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
500
Downloads of v 1.0:
500
Maintainer(s):
Software Author(s):
- Chantisnake
ctest 1.0
- 1
- 2
- 3
Some Checks Have Failed or Are Not Yet Complete
Not All Tests Have Passed
This package was approved by moderator ferventcoder on 11 Jul 2016.
This package is unlisted and hidden from package listings.
This is a testing utility for you chocolatey package.
When you run ctest
, you need to give it a path.
Then ctest script will index all the file in that folder recursively.
Then it will match all the *.nuspec
file and do choco pack
on the *.nuspec
file respectively.
Then try to install and uninstall all the packed chocolatey package.
you can find this project at github: https://github.com/chantisnake/ctest
param (
[string] $Path = './',
[switch] $pre,
[switch] $Run,
[Switch] $Continue
)
$chocoFilePath = 'choco'
function Test-Admin {
$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$principal = new-object System.Security.Principal.WindowsPrincipal($identity)
$admin = [System.Security.Principal.WindowsBuiltInRole]::Administrator
$principal.IsInRole($admin)
}
function Get-Files($path = $pwd)
{
foreach ($item in Get-ChildItem $path)
{
if (Test-Path $item.FullName -PathType Container)
{
$item
Get-Files -path $item.FullName
}
else
{
$item
}
}
}
function Start-PackTest($packagePath, $packageName) {
Write-Host ''
Write-Host 'starting packing test' -ForegroundColor Magenta
$location = Get-Location
Set-Location $packagePath
# run command
$process = Start-Process -FilePath $chocoFilePath -ArgumentList 'pack' -NoNewWindow -Wait -ErrorAction Stop -PassThru
$exitCode = $process.ExitCode
# see if command is successful
if ($exitCode -eq 0) {
Write-Host ''
Write-Host "choco pack for package " -NoNewline -ForegroundColor Green
Write-Host $packageName -ForegroundColor Magenta -NoNewline
Write-Host " exit normally with exit code 0" -ForegroundColor Green
$exitOption = Read-Host 'press q to quit, press Enter to continue'
$exitOption
}
else {
Write-Host ''
Write-Warning "choco pack for package $packageName fail with exit code $exitCode"
$exitOption = Read-Host 'press q to quit, press Enter to continue'
$exitOption
}
Set-Location $location
}
function Start-InstallTest ($packagePath ,$packageName) {
Write-Host ''
Write-Host 'starting install test' -ForegroundColor Magenta
$location = Get-Location
Set-Location $packagePath
# run command
if($pre){
$process = Start-Process -FilePath $chocoFilePath -ArgumentList "install $packageName -fdv -s $pwd -pre" -NoNewWindow -Wait -ErrorAction Stop -PassThru
}
else {
$process = Start-Process -FilePath $chocoFilePath -ArgumentList "install $packageName -fdv -s $pwd" -NoNewWindow -Wait -ErrorAction Stop -PassThru
}
$exitCode = $process.ExitCode
# see if command is successful
if ($exitCode -eq 0) {
Write-Host ''
Write-Host "choco install for package " -NoNewline -ForegroundColor Green
Write-Host $packageName -ForegroundColor Magenta -NoNewline
Write-Host " exit normally with exit code 0" -ForegroundColor Green
$exitOption = Read-Host 'press q to quit, press Enter to continue'
$exitOption
}
else {
Write-Host ''
Write-Warning "choco install for package $packageName fail with exit code $exitCode"
$exitOption = Read-Host 'press q to quit, press Enter to continue'
$exitOption
}
# go back to starting location
Set-Location $location
}
function Start-UninstallTest ($packagePath, $packageName) {
Write-Host ''
Write-Host 'starting uninstall test' -ForegroundColor Magenta
# run command
$process = Start-Process -FilePath $chocoFilePath -ArgumentList "uninstall $packageName -debug" -NoNewWindow -Wait -ErrorAction Stop -PassThru
$exitCode = $process.ExitCode
# see if command is successful
if ($exitCode -eq 0) {
Write-Host ''
Write-Host "choco uninstall for package " -NoNewline -ForegroundColor Green
Write-Host $packageName -ForegroundColor Magenta -NoNewline
Write-Host " exit normally with exit code 0" -ForegroundColor Green
$exitOption = Read-Host 'press q to quit, press Enter to continue'
$exitOption
}
else {
Write-Host ''
Write-Warning "choco uninstall for package $packageName failed with exit code $exitCode"
$exitOption = Read-Host 'press q to quit, press Enter to ignore the error and continue'
$exitOption
}
}
function Start-ChocoPush ($packagePath) {
$location = Get-Location
Set-Location $packagePath
$process = Start-Process -FilePath $chocoFilePath -ArgumentList 'push' -NoNewWindow -Wait -ErrorAction Stop -PassThru
if ($process.ExitCode -eq 0) {
Write-Host 'push Successful' -ForegroundColor Green
}
else {
Write-Warning 'Push have failed, you may need to mannul push later'
}
Set-Location $location
}
function Invoke-CTestCore ($infoObject) {
foreach ($package in $infoObject.psobject.properties) {
# get basic info
$packagePath = [System.IO.Path]::GetDirectoryName($package.name)
$packageName = [System.IO.Path]::GetFileNameWithoutExtension($package.name)
Write-Host ''
Write-Host 'starting to test package with the name' -ForegroundColor Green
Write-Host $packageName -ForegroundColor Green
# starts packing test
if ($package.Value.packed) {
Write-Host 'Package has passed the pack test'
}
else {
$exitOption = Start-PackTest -packagePath $packagePath -packageName $packageName
# handle exit option
if ($exitOption -eq 'q') {
# save infoDict and exit
$infoObject | ConvertTo-Json > ./ctest_profile
Write-Host 'info saved, you can run `ctest <path> -continue` to restore the test' -ForgroundColor Green
return
}
else {
# update infoDict
$package.Value.packed = $true
}
}
# start installing package
if ($package.Value.install) {
Write-Host 'Package has passed the install test'
}
else {
$exitOption = Start-InstallTest -packagePath $packagePath -packageName $packageName
# handle exit option
if ($exitOption -eq 'q') {
# save infoDict and exit
$infoObject | ConvertTo-Json > ./ctest_profile
Write-Host 'info saved, you can run `ctest <path> -continue` to restore the test' -ForgroundColor Green
return
}
else {
# update infoDict
$package.Value.install = $true
}
}
# start uninstall test
if ($package.Value.uninstall) {
Write-Host 'Package has passed the uninstall test'
}
else {
$exitOption = Start-UninstallTest -packageName $packageName
# handle exit option
if ($exitOption -eq 'q') {
# save infoDict and exit
$infoObject | ConvertTo-Json > ./ctest_profile
Write-Host 'info saved, you can run `ctest <path> -continue` to restart the test' -ForgroundColor Green
return
}
else {
# update infoDict
$package.Value.uninstall = $true
}
}
}
Write-Host 'Test finished' -ForegroundColor Green
Write-Host 'All test is passed, do you want to push?' -ForegroundColor Magenta
$option = Read-Host 'Press [Y]es to push, everything else will exit the script'
if ($option.ToLower() -eq 'y' -or $option.ToLower() -eq 'yes') {
Start-ChocoPush -packagePath $packagePath
}
Write-Host 'do you want to reinstall the package in case you need to use it?'
$option = Read-Host 'press enter to reinstall, input q to exit'
if ($option.ToLower() -ne 'q' -and $option.ToLower() -ne 'quit') {
Start-InstallTest -packagePath $packagePath -packageName $packageName
}
}
function Start-CTest {
Write-Host ''
Write-Host 'indexing the directory' -ForegroundColor Green
Write-Host 'this can take super long time if you are running in huge dir' -ForegroundColor Magenta
Write-Host 'so Please do not start this script in a huge dir' -ForegroundColor Magenta
$files = Get-Files -path $PWD
$nuspecFiles = $files| where {$_.name -match '.*\.nuspec'}
Write-Host ''
Write-Host 'here is all the nuspec file I have found' -ForegroundColor Green
Write-Host $nuspecFiles -ForegroundColor Magenta
Write-Host 'we will start testing with all these files'
Read-Host 'Press Enter to Continue'
Write-Host ''
Write-Host 'initializing test' -ForegroundColor Magenta
$default = @{'packed' = $false; 'install'= $false; 'uninstall'=$false}
# creating info object
$infoObject = New-Object -TypeName psobject
foreach ($file in $nuspecFiles) {
Add-Member -InputObject $infoObject -MemberType NoteProperty -Name $file.FullName -Value $default
}
Write-Host 'infoObject is initiated' -ForegroundColor Magenta
Invoke-CTestCore $infoObject
}
function Resume-CTest {
# reading the infoDict
Write-Host 'Reading the old profile'
$infoObject = Get-Content ./ctest_profile | ConvertFrom-Json
Invoke-CTestCore -infoObject $infoObject
}
function Initialize-ResumedCTest {
Write-Host 'Trying to find the old Profile'
if (-Not (Test-Path ./ctest_profile)) {
Write-Warning 'previous ctest profile not found.'
Write-Warning 'Starting a new test'
Start-CTest
}
else {
Write-Host 'old Profile found'
Resume-CTest
}
}
function Initialize-AutoCTest{
if(Test-Path ./ctest_profile) {
Write-Host 'found the old test profile' -ForegroundColor Magenta
Write-Host 'Do you want to continue the old test?' -ForegroundColor Magenta
$option = Read-Host 'enter [Y]es for continue else we will start a new test'
if ($option.ToLower -eq 'yes' -or $option.ToLower() -eq 'y') {
Write-Host 'continue the old test' -ForgroundColor Magenta
Resume-CTest
}
else {
Write-Host 'removing the old test profile' -ForegroundColor Magenta
Remove-Item ./ctest_profile
Write-Host 'starting a new test' -ForgroundColor Magenta
Start-CTest
}
}
else {
Write-Host 'cannot find the old test profile' -ForegroundColor Magenta
Write-Host 'starting a new test' -ForegroundColor Magenta
Start-CTest
}
}
####################################################
# MAIN
####################################################
if (-Not (Test-Admin)) {
Write-Warning 'You are not running in admin. Your test may fail'
Read-Host 'Press Ctrl-C to quit, Press Enter to ignore the warning and continue'
}
$location = Get-Location
Set-Location $path
if ($Run) {
Start-CTest
}
elseif ($Continue) {
Initialize-ResumedCTest
}
else {
Initialize-AutoCTest
}
Set-Location $location
Write-Host 'exiting the script. Have a Nice day' -ForegroundColor Green
Log in or click on link to see number of positives.
- ctest.1.0.nupkg (e031de4c96a7) - ## / 54
In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).
Chocolatey Pro provides runtime protection from possible malware.
This package has no dependencies.
Ground Rules:
- This discussion is only about ctest and the ctest package. If you have feedback for Chocolatey, please contact the Google Group.
- This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
- The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
- Tell us what you love about the package or ctest, or tell us what needs improvement.
- Share your experiences with the package, or extra configuration or gotchas that you've found.
- If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.