Skip to content

Commit

Permalink
More robust image name resolution. Added test for image name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bajger committed Feb 2, 2024
1 parent 6ef66cb commit 7784c5d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/PharoLauncher-Core/PhLImageProcess.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ PhLImageProcess class >> newFrom: osOutputLine [
{ #category : #accessing }
PhLImageProcess >> imageName [


|fileName|
self imagePath ifEmpty: [ ^ '' ].
^ (self imagePath copyAfterLast: FileSystem disk delimiter) copyUpTo: $.
fileName := self imagePath copyAfterLast: FileSystem disk delimiter.
fileName ifEmpty: [ fileName := self imagePath ].
^ fileName copyUpTo: $.
]

{ #category : #accessing }
Expand Down
35 changes: 35 additions & 0 deletions src/PharoLauncher-Tests-Core/PhLImageProcessTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,41 @@ Class {
#category : #'PharoLauncher-Tests-Core'
}

{ #category : #private }
PhLImageProcessTest >> imagePathNameCandidates [

|paths delimiter|
paths := OrderedCollection new.
delimiter := FileSystem disk delimiter.

paths add: (String streamContents: [:aStream |
aStream nextPutAll: 'some';
nextPut: delimiter;
nextPutAll: 'very';
nextPut: delimiter;
nextPutAll: 'long';
nextPut: delimiter;
nextPutAll: 'path';
nextPut: delimiter;
nextPutAll: 'myImage1.image'
]
).
paths add: 'myImage2.image'.
^ paths
]

{ #category : #tests }
PhLImageProcessTest >> testImageName [

| imageNames |
imageNames := self imagePathNameCandidates collect: [:aPath |
PhLImageProcess new
imagePath: aPath;
imageName
].
self assert: (imageNames includesAll: #('myImage1' 'myImage2')).
]

{ #category : #tests }
PhLImageProcessTest >> testNewFrom [

Expand Down

0 comments on commit 7784c5d

Please sign in to comment.