Skip to content

Commit de4497e

Browse files
committed
use a copy of the image for tests.
1 parent a791f1c commit de4497e

3 files changed

Lines changed: 52 additions & 18 deletions

File tree

src/PharoLauncher-Tests-Commands/PhLLaunchImageCommandTest.class.st

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ PhLLaunchImageCommandTest >> initScript [
3939

4040
{ #category : 'helper' }
4141
PhLLaunchImageCommandTest >> launchImage [
42-
self selectImage.
42+
4343
process ifNotNil: [ self error: 'Currently one execution of image per test case.' ].
4444
process := runCommand execute
4545
]
@@ -120,12 +120,7 @@ PhLLaunchImageCommandTest >> testAttachingInitializationScriptSetFlagToShouldRun
120120
PhLLaunchImageCommandTest >> testCanLaunchImage [
121121
self timeLimit: 30 seconds.
122122

123-
image := PhLPharoStableImageResource current image.
124-
125-
presenter
126-
unselectAll;
127-
selection: { image }.
128-
123+
self useNewStableImageAndSetItAsSelectedImageInImagesPresenter.
129124
image addLaunchConfiguration:
130125
(image defaultLaunchConfiguration asLaunchConfiguration
131126
vmArguments: #('--headless'); "be able to run test without X session"
@@ -141,6 +136,7 @@ PhLLaunchImageCommandTest >> testCanLaunchImage [
141136
{ #category : 'tests' }
142137
PhLLaunchImageCommandTest >> testExecutingImageWithScriptShouldSetFlagToShouldNotRun [
143138

139+
self useNewStableImageAndSetItAsSelectedImageInImagesPresenter.
144140
self addInitializationScriptToImage.
145141
self launchImage.
146142

@@ -189,3 +185,12 @@ PhLLaunchImageCommandTest >> testRunningAnImageRemovesTheInitializationScript [
189185

190186
self assert: image initializationScript path equals: self initScript path
191187
]
188+
189+
{ #category : 'helper' }
190+
PhLLaunchImageCommandTest >> useNewStableImageAndSetItAsSelectedImageInImagesPresenter [
191+
192+
image := PhLPharoStableImageResource current newImage.
193+
presenter
194+
unselectAll;
195+
selection: { image }
196+
]

src/PharoLauncher-Tests-Commands/PhLLaunchImageFromDiskCommandTest.class.st

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Class {
1010
#package : 'PharoLauncher-Tests-Commands'
1111
}
1212

13+
{ #category : 'accessing' }
14+
PhLLaunchImageFromDiskCommandTest class >> resources [
15+
16+
^ { PhLPharoStableImageResource }
17+
]
18+
1319
{ #category : 'running' }
1420
PhLLaunchImageFromDiskCommandTest >> setUp [
1521

src/PharoLauncher-Tests-Core/PhLPharoStableImageResource.class.st

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ Class {
1313
#package : 'PharoLauncher-Tests-Core'
1414
}
1515

16-
{ #category : 'fetching' }
16+
{ #category : 'private' }
17+
PhLPharoStableImageResource >> copyImageTo: aDirectory [
18+
19+
| command |
20+
command := 'cp -R ', self extractionDir fullName surroundedBySingleQuotes , ' ', aDirectory fullName surroundedBySingleQuotes.
21+
LibC runCommand: command
22+
]
23+
24+
{ #category : 'private' }
1725
PhLPharoStableImageResource >> downloadPharoStableImage [
1826

1927
imageZipFile := self workingDir / 'stable-64.zip'.
@@ -22,30 +30,45 @@ PhLPharoStableImageResource >> downloadPharoStableImage [
2230
toFile: imageZipFile
2331
]
2432

25-
{ #category : 'fetching' }
33+
{ #category : 'private' }
2634
PhLPharoStableImageResource >> extractPharoImage [
27-
28-
| imageFile |
35+
36+
self extractionDir ensureCreateDirectory.
37+
2938
PhLVirtualMachineManager
3039
unzip: self imageZipFile
31-
to: self workingDir.
32-
33-
imageFile := (self workingDir childrenMatching: '*.image') first.
34-
image := PhLImage location: imageFile.
40+
to: self extractionDir
41+
]
42+
43+
{ #category : 'private - accessing' }
44+
PhLPharoStableImageResource >> extractionDir [
45+
46+
^ self workingDir / 'extracted'
3547
]
3648

37-
{ #category : 'accessing' }
49+
{ #category : 'private - accessing' }
3850
PhLPharoStableImageResource >> image [
3951

4052
^ image
4153
]
4254

43-
{ #category : 'accessing' }
55+
{ #category : 'private - accessing' }
4456
PhLPharoStableImageResource >> imageZipFile [
4557

4658
^ imageZipFile
4759
]
4860

61+
{ #category : 'running' }
62+
PhLPharoStableImageResource >> newImage [
63+
64+
| imageDir imageFile |
65+
imageDir := self workingDir / (UUID new asString).
66+
self copyImageTo: imageDir.
67+
imageFile := (imageDir childrenMatching: '*.image') first.
68+
69+
^ PhLImage location: imageFile
70+
]
71+
4972
{ #category : 'running' }
5073
PhLPharoStableImageResource >> setUp [
5174

@@ -62,7 +85,7 @@ PhLPharoStableImageResource >> tearDown [
6285
super tearDown
6386
]
6487

65-
{ #category : 'accessing' }
88+
{ #category : 'private - accessing' }
6689
PhLPharoStableImageResource >> workingDir [
6790

6891
^ workingDir

0 commit comments

Comments
 (0)