Skip to content

Commit

Permalink
- make the file collector returns the list of files.
Browse files Browse the repository at this point in the history
- rename the api visitedDocumentFiles
  • Loading branch information
Ducasse committed Sep 12, 2024
1 parent 6cf9a2b commit 948ac50
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
16 changes: 8 additions & 8 deletions src/Microdown-BookTester-Tests/MicFileCollectorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MicFileCollectorTest >> testDoubleLoopsAndThatUnexistingInputIsCorrectlyResolved
self startVisitingFromTheRoot: section2.

self
assert: visitor visitedDocumentFiles
assert: visitor visitedFileStrings
equals:
Set <- {
'/myDirectory/section1.md' .
Expand Down Expand Up @@ -61,7 +61,7 @@ MicFileCollectorTest >> testFileCollectorHandlesLoopFromSection3ToMain [
section4"

self
assert: visitor visitedDocumentFiles
assert: visitor visitedFileStrings
equals:
{
'/myDirectory/section1.md' .
Expand All @@ -82,7 +82,7 @@ MicFileCollectorTest >> testLoopOfFilesReferencingEachOther [
self startVisitingFromTheRoot: section1.

self
assert: visitor visitedDocumentFiles
assert: visitor visitedFileStrings
equals:
Set <- {
'/myDirectory/section1.md'.
Expand All @@ -97,7 +97,7 @@ MicFileCollectorTest >> testMultipleReferencesOfFileThatDoesNotExist [
self startVisitingFromTheRoot: section1.

self
assert: visitor visitedDocumentFiles
assert: visitor visitedFileStrings
equals:
Set <- {
'/myDirectory/section1.md' .
Expand All @@ -119,7 +119,7 @@ MicFileCollectorTest >> testMultipleReferencesToTheSameFile [
self startVisitingFromTheRoot: section1.

self
assert: visitor visitedDocumentFiles
assert: visitor visitedFileStrings
equals:
{ '/myDirectory/section1.md'. '/myDirectory/sections/section2.md' . '/myDirectory/sections/section4.md' } asSet

Expand All @@ -132,7 +132,7 @@ MicFileCollectorTest >> testOnlyGoDownInFolders [
self startVisitingFromTheRoot: section1.

self
assert: visitor visitedDocumentFiles
assert: visitor visitedFileStrings
equals:
Set <- {
'/myDirectory/section1.md' .
Expand All @@ -149,7 +149,7 @@ MicFileCollectorTest >> testOnlyGoUpInFoldersStartingFromAnotherRoot [
self startVisitingFromTheRoot: section4.

self
assert: visitor visitedDocumentFiles
assert: visitor visitedFileStrings
equals:
Set <- {
'/myDirectory/section1.md'.
Expand All @@ -166,7 +166,7 @@ MicFileCollectorTest >> testUnreferencedFileAreNotHandled [
self createProjectWithUnreferencedFiles3And5.
self startVisitingFromTheRoot: section1.

self assert: visitor visitedDocumentFiles equals: Set
self assert: visitor visitedFileStrings equals: Set
<-
{ '/myDirectory/section1.md'. '/myDirectory/sections/section2.md'.
'/myDirectory/sections/section4.md' }
Expand Down
6 changes: 6 additions & 0 deletions src/Microdown-BookTester/MicAnalysisReportWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ MicAnalysisReportWriter >> initialize [
results := OrderedCollection new
]

{ #category : 'testing' }
MicAnalysisReportWriter >> isOkay [

^ results isEmpty
]

{ #category : 'reporting' }
MicAnalysisReportWriter >> report [

Expand Down
28 changes: 18 additions & 10 deletions src/Microdown-BookTester/MicFileCollector.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ Class {
#superclass : 'MicrodownVisitor',
#instVars : [
'rootDirectory',
'visited',
'unexistingFiles',
'inputFiles'
'inputFiles',
'visitedFileStrings',
'visitedFiles'
],
#category : 'Microdown-BookTester',
#package : 'Microdown-BookTester'
}

{ #category : 'visiting' }
{ #category : 'initialization' }
MicFileCollector >> initialize [

super initialize.
rootDirectory := FileSystem workingDirectory.
visited := Set new.
visitedFileStrings := Set new.
unexistingFiles := Set new.
visitedFiles := OrderedCollection new.
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -65,9 +67,10 @@ MicFileCollector >> visitRoot: micDocument [
[ worklist isEmpty ] whileFalse: [
| currentDocument |
currentDocument := worklist removeFirst.
visited add: currentDocument fromFile.
visitedFileStrings add: currentDocument fromFile.
currentDocument resolveYourself.

visitedFiles add: currentDocument.

inputFiles := OrderedCollection new.
"treat all the inputFile from the current document"
self visitChildrenOf: currentDocument.
Expand All @@ -81,8 +84,7 @@ MicFileCollector >> visitRoot: micDocument [

"Since we are just checking that a file exist it does not matter when we check.
We do not have to wait until we walk through all the files."

(visited includes: fr path pathString) ifFalse: [
(visitedFileStrings includes: fr path pathString) ifFalse: [
[
doc := Microdown parseFile: fr.
worklist addFirst: doc ]
Expand All @@ -91,7 +93,13 @@ MicFileCollector >> visitRoot: micDocument [
]

{ #category : 'accessing' }
MicFileCollector >> visitedDocumentFiles [
MicFileCollector >> visitedFileStrings [

^ visitedFileStrings
]

{ #category : 'accessing' }
MicFileCollector >> visitedFiles [

^ visited
^ visitedFiles
]
7 changes: 4 additions & 3 deletions src/Microdown-BookTester/MicReferenceChecker.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Class {
'anchors',
'duplicatedAnchors',
'results',
'rootDirectory'
'rootDirectory',
'listOfFiles'
],
#category : 'Microdown-BookTester',
#package : 'Microdown-BookTester'
Expand Down Expand Up @@ -78,14 +79,14 @@ MicReferenceChecker >> checkList: aCollection [
{ #category : 'main API' }
MicReferenceChecker >> checkProject: aFileReference [

| mainMic collector listOfFiles |
| mainMic collector |
mainMic := Microdown parseFile: aFileReference.
collector := MicFileCollector new.
collector
rootDirectory: rootDirectory;
visit: mainMic.
self handleUndefinedFilesFrom: collector.
listOfFiles := collector visitedDocumentFiles collect: [ :file |
listOfFiles := collector visitedFileStrings collect: [ :file |
rootDirectory resolve: file ].
self checkList: listOfFiles
]
Expand Down

0 comments on commit 948ac50

Please sign in to comment.