Skip to content

Commit

Permalink
Merge pull request #856 from pillar-markup/fixingFileSystem
Browse files Browse the repository at this point in the history
Fixing fileSystem
  • Loading branch information
Ducasse authored Aug 14, 2024
2 parents e4b15b9 + 9910896 commit d8722b8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MicFileCollectorTest >> startVisitingFromTheRoot: root [
mainMic := Microdown parseFile: root.
visitor := MicFileCollector new.
visitor
fileSystem: fs;
rootDirectory: dir;
visit: mainMic.
]

Expand Down
27 changes: 9 additions & 18 deletions src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -294,22 +294,13 @@ See *@ancS1@*
' ]
]

{ #category : 'running' }
MicReferenceCheckerTest >> setUp [

super setUp.
fs := self fileSystem.
dir := fs / 'myDirectory'.
dir ensureCreateDirectory
]

{ #category : 'tests - single file ok references' }
MicReferenceCheckerTest >> testDefAndReferToAMathEquationInFile [

| visitor |
self defEq1AndReferToEq1.
visitor := MicReferenceChecker new.
visitor fileSystem: fs.
visitor rootDirectory: dir.
visitor checkProject: defEq1AndReferToEq1.
self assert: visitor isOkay.
self assert: visitor results isEmpty
Expand All @@ -321,7 +312,7 @@ MicReferenceCheckerTest >> testDefFig1AndRefToAncS0UnknowAnchor [
| visitor |
self defFig1AndRefToAncS0.
visitor := MicReferenceChecker new.
visitor fileSystem: fs.
visitor rootDirectory: dir.
visitor checkProject: defFig1AndRefToAnsC0.
self deny: visitor isOkay.
self assert: visitor results first anchorLabel equals: 'ancS0'.
Expand Down Expand Up @@ -349,7 +340,7 @@ MicReferenceCheckerTest >> testDefFig1AndReferToFig1 [
| visitor |
self defFig1AndRefFig1.
visitor := MicReferenceChecker new.
visitor fileSystem: fs.
visitor rootDirectory: dir.
visitor checkProject: defAndRefFig1.
self assert: visitor isOkay.
self assert: visitor results isEmpty
Expand All @@ -372,7 +363,7 @@ MicReferenceCheckerTest >> testDefS1ButRefersToS0UnknownAnchor [
| visitor |
self fileDefAncS1UndAncS0.
visitor := MicReferenceChecker new.
visitor fileSystem: fs.
visitor rootDirectory: dir.
visitor checkProject: fileDefAncS1UndAncS0.
self deny: visitor isOkay.
self assert: visitor results size equals: 1.
Expand Down Expand Up @@ -590,7 +581,7 @@ MicReferenceCheckerTest >> testFullProjectWithFowardAndBackWardRefBetweenTwoFile
| checker |
self createProjectCorrectReferencesOnTwoFiles.
checker := MicReferenceChecker new.
checker fileSystem: fs.
checker rootDirectory: dir.
checker checkProject: section1.
self assert: checker isOkay
]
Expand All @@ -601,7 +592,7 @@ MicReferenceCheckerTest >> testFullProjectWithReferencesToUnknowAnchor [
| checker dict unk undefined |
self createProjectBadAndCorrectReferences.
checker := MicReferenceChecker new.
checker fileSystem: fs.
checker rootDirectory: dir.
checker checkProject: section1.
self deny: checker isOkay.
self assert: checker results size equals: 2.
Expand Down Expand Up @@ -690,7 +681,7 @@ MicReferenceCheckerTest >> testRefToUnkS1 [
| visitor |
self refToUnkS1.
visitor := MicReferenceChecker new.
visitor fileSystem: fs.
visitor rootDirectory: dir.
visitor checkProject: refToUnkS1.
self deny: visitor isOkay

Expand All @@ -703,7 +694,7 @@ MicReferenceCheckerTest >> testRefersToUnkAncS1 [
| visitor |
self fileRefAncS1.
visitor := MicReferenceChecker new.
visitor fileSystem: fs.
visitor rootDirectory: dir.
visitor checkProject: refAncS1.
self deny: visitor isOkay.
self assert: visitor results size equals: 1.
Expand Down Expand Up @@ -750,7 +741,7 @@ MicReferenceCheckerTest >> testUndefinedInputFilesAreMentionedInResult [
| checker |
self createProjectWithUnexistingSection3And5.
checker := MicReferenceChecker new.
checker fileSystem: fs.
checker rootDirectory: dir.
checker checkProject: section1.

self assert: checker results size equals: 3.
Expand Down
18 changes: 15 additions & 3 deletions src/Microdown-BookTester/MicFileCollector.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
#name : 'MicFileCollector',
#superclass : 'MicrodownVisitor',
#instVars : [
'fileSystem',
'rootDirectory',
'visited',
'unexistingFiles',
'inputFiles'
Expand All @@ -38,11 +38,23 @@ MicFileCollector >> fileSystem: aFileSystem [
MicFileCollector >> initialize [

super initialize.
fileSystem := FileSystem disk.
rootDirectory := FileSystem workingDirectory.
visited := Set new.
unexistingFiles := Set new.
]

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

^ rootDirectory
]

{ #category : 'accessing' }
MicFileCollector >> rootDirectory: aFileReference [

rootDirectory := aFileReference
]

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

Expand Down Expand Up @@ -75,7 +87,7 @@ MicFileCollector >> visitRoot: micDocument [
inputFiles do: [ :inputFile |
| fr doc |
"later we will have to fix this ugly expression"
fr := self fileSystem referenceTo:
fr := self rootDirectory resolve:
(inputFile arguments at: 'path') uri asFileReference
pathString.

Expand Down
16 changes: 11 additions & 5 deletions src/Microdown-BookTester/MicReferenceChecker.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Class {
'anchors',
'duplicatedAnchors',
'results',
'fileSystem'
'rootDirectory'
],
#category : 'Microdown-BookTester',
#package : 'Microdown-BookTester'
Expand Down Expand Up @@ -90,11 +90,11 @@ MicReferenceChecker >> checkProject: aFileReference [
mainMic := Microdown parseFile: aFileReference.
collector := MicFileCollector new.
collector
fileSystem: fileSystem;
rootDirectory: rootDirectory;
visit: mainMic.
self handleUndefinedFilesFrom: collector.
listOfFiles := collector visitedDocumentFiles collect: [ :file |
fileSystem referenceTo: file ].
rootDirectory resolve: file ].
self checkList: listOfFiles
]

Expand All @@ -119,7 +119,7 @@ MicReferenceChecker >> duplicatedAnchors [
{ #category : 'accessing' }
MicReferenceChecker >> fileSystem: aFileSystem [

fileSystem := aFileSystem
rootDirectory := aFileSystem
]

{ #category : 'visiting' }
Expand Down Expand Up @@ -160,7 +160,7 @@ MicReferenceChecker >> initialize [

super initialize.

fileSystem := FileSystem disk.
rootDirectory := FileSystem workingDirectory.
results := OrderedCollection new.
references := OrderedCollection new.
anchors := OrderedCollection new.
Expand Down Expand Up @@ -203,6 +203,12 @@ MicReferenceChecker >> results [
^ results
]

{ #category : 'accessing' }
MicReferenceChecker >> rootDirectory: aFileReferemce [

rootDirectory := aFileReferemce
]

{ #category : 'internal' }
MicReferenceChecker >> unknownAnchors [

Expand Down

0 comments on commit d8722b8

Please sign in to comment.