Skip to content

Instantly share code, notes, and snippets.

@mabdi
Last active April 22, 2020 12:57
Show Gist options
  • Save mabdi/230988081cdac6882a87314519c62620 to your computer and use it in GitHub Desktop.
Save mabdi/230988081cdac6882a87314519c62620 to your computer and use it in GitHub Desktop.
Pharo Script: get number of classes, test classes, ...
| search packages classes testPackages tests focousedTests testMethodFocoused stat testrun |
search := 'project' asLowercase.
"replace with loading code"
Metacello new
baseline: '***';
repository: 'github://****';
load.
"end of loading code"
packages := RPackage organizer packages select: [:p | p name asLowercase includesSubstring: search ].
classes := packages flatCollect: [ :p | p definedClasses ].
testPackages := packages
select: [ :p | p definedClasses anySatisfy: [ :c | c isTestCase ] ].
tests := testPackages
flatCollect:
[ :p | p definedClasses select: [ :c | c allSuperclasses includes: TestCase ] ].
testrun := TestAsserter classForTestResult new.
tests do: [:ts | ts run: testrun].
focousedTests := tests select: [ :s | s smallAmpTargetClasses isNotNil ].
testMethodFocoused := focousedTests flatCollect: #allTestSelectors.
stat := { #packages -> packages size.
#classes -> classes size.
#testPackages -> testPackages size.
#tests -> tests size.
#focousedTests -> focousedTests size.
#focousedTestsMethods -> testMethodFocoused size.
#testsFails -> testrun failureCount.
#testsErrors -> testrun errorCount.
#testsPasses -> testrun passedCount.
} asString.
(FileSystem disk workingDirectory / (search,'.stat')) writeStream
nextPutAll: stat;
close.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment