@@ -10,7 +10,7 @@ import {
1010 validatePythonVersionFormatForPyPy ,
1111 isCacheFeatureAvailable ,
1212 getVersionInputFromFile ,
13- getVersionInputFromPlainFile ,
13+ getVersionsInputFromPlainFile ,
1414 getVersionInputFromTomlFile ,
1515 getNextPageUrl ,
1616 isGhes ,
@@ -24,10 +24,10 @@ jest.mock('@actions/core');
2424
2525describe ( 'validatePythonVersionFormatForPyPy' , ( ) => {
2626 it . each ( [
27- [ '3.6 ' , true ] ,
28- [ '3.7 ' , true ] ,
29- [ '3.6 .x' , false ] ,
30- [ '3.7 .x' , false ] ,
27+ [ '3.12 ' , true ] ,
28+ [ '3.13 ' , true ] ,
29+ [ '3.12 .x' , false ] ,
30+ [ '3.13 .x' , false ] ,
3131 [ '3.x' , false ] ,
3232 [ '3' , false ]
3333 ] ) ( '%s -> %s' , ( input , expected ) => {
@@ -95,24 +95,52 @@ const tempDir = path.join(
9595) ;
9696
9797describe ( 'Version from file test' , ( ) => {
98- it . each ( [ getVersionInputFromPlainFile , getVersionInputFromFile ] ) (
98+ it . each ( [ getVersionsInputFromPlainFile , getVersionInputFromFile ] ) (
9999 'Version from plain file test' ,
100100 async _fn => {
101101 await io . mkdirP ( tempDir ) ;
102102 const pythonVersionFileName = 'python-version.file' ;
103103 const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
104- const pythonVersionFileContent = '3.7 ' ;
104+ const pythonVersionFileContent = '3.13 ' ;
105105 fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
106106 expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ pythonVersionFileContent ] ) ;
107107 }
108108 ) ;
109+ it . each ( [ getVersionsInputFromPlainFile , getVersionInputFromFile ] ) (
110+ 'Versions from multiline plain file test' ,
111+ async _fn => {
112+ await io . mkdirP ( tempDir ) ;
113+ const pythonVersionFileName = 'python-version.file' ;
114+ const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
115+ const pythonVersionFileContent = '3.13\r\n3.12' ;
116+ fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
117+ expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ '3.13' , '3.12' ] ) ;
118+ }
119+ ) ;
120+ it . each ( [ getVersionsInputFromPlainFile , getVersionInputFromFile ] ) (
121+ 'Version from complex plain file test' ,
122+ async _fn => {
123+ await io . mkdirP ( tempDir ) ;
124+ const pythonVersionFileName = 'python-version.file' ;
125+ const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
126+ const pythonVersionFileContent =
127+ '3.13/envs/virtualenv\r# 3.12\n3.11\r\n3.10\r\n 3.9 \r\n' ;
128+ fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
129+ expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [
130+ '3.13' ,
131+ '3.11' ,
132+ '3.10' ,
133+ '3.9'
134+ ] ) ;
135+ }
136+ ) ;
109137 it . each ( [ getVersionInputFromTomlFile , getVersionInputFromFile ] ) (
110138 'Version from standard pyproject.toml test' ,
111139 async _fn => {
112140 await io . mkdirP ( tempDir ) ;
113141 const pythonVersionFileName = 'pyproject.toml' ;
114142 const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
115- const pythonVersion = '>=3.7 .0' ;
143+ const pythonVersion = '>=3.13 .0' ;
116144 const pythonVersionFileContent = `[project]\nrequires-python = "${ pythonVersion } "` ;
117145 fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
118146 expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ pythonVersion ] ) ;
@@ -124,7 +152,7 @@ describe('Version from file test', () => {
124152 await io . mkdirP ( tempDir ) ;
125153 const pythonVersionFileName = 'pyproject.toml' ;
126154 const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
127- const pythonVersion = '>=3.7 .0' ;
155+ const pythonVersion = '>=3.13 .0' ;
128156 const pythonVersionFileContent = `[tool.poetry.dependencies]\npython = "${ pythonVersion } "` ;
129157 fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
130158 expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ pythonVersion ] ) ;
@@ -145,9 +173,9 @@ describe('Version from file test', () => {
145173 async _fn => {
146174 const toolVersionFileName = '.tool-versions' ;
147175 const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
148- const toolVersionContent = 'python 3.9.10 \nnodejs 16' ;
176+ const toolVersionContent = 'python 3.13.2 \nnodejs 16' ;
149177 fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
150- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.9.10 ' ] ) ;
178+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.13.2 ' ] ) ;
151179 }
152180 ) ;
153181
@@ -156,9 +184,9 @@ describe('Version from file test', () => {
156184 async _fn => {
157185 const toolVersionFileName = '.tool-versions' ;
158186 const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
159- const toolVersionContent = '# python 3.8 \npython 3.9 ' ;
187+ const toolVersionContent = '# python 3.13 \npython 3.12 ' ;
160188 fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
161- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.9 ' ] ) ;
189+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.12 ' ] ) ;
162190 }
163191 ) ;
164192
@@ -167,9 +195,9 @@ describe('Version from file test', () => {
167195 async _fn => {
168196 const toolVersionFileName = '.tool-versions' ;
169197 const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
170- const toolVersionContent = ' python 3.10 ' ;
198+ const toolVersionContent = ' python 3.13 ' ;
171199 fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
172- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.10 ' ] ) ;
200+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.13 ' ] ) ;
173201 }
174202 ) ;
175203
@@ -178,9 +206,9 @@ describe('Version from file test', () => {
178206 async _fn => {
179207 const toolVersionFileName = '.tool-versions' ;
180208 const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
181- const toolVersionContent = 'python v3.9.10 ' ;
209+ const toolVersionContent = 'python v3.13.2 ' ;
182210 fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
183- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.9.10 ' ] ) ;
211+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ '3.13.2 ' ] ) ;
184212 }
185213 ) ;
186214
@@ -189,9 +217,9 @@ describe('Version from file test', () => {
189217 async _fn => {
190218 const toolVersionFileName = '.tool-versions' ;
191219 const toolVersionFilePath = path . join ( tempDir , toolVersionFileName ) ;
192- const toolVersionContent = 'python pypy3.10-7.3.14 ' ;
220+ const toolVersionContent = 'python pypy3.10-7.3.19 ' ;
193221 fs . writeFileSync ( toolVersionFilePath , toolVersionContent ) ;
194- expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ 'pypy3.10-7.3.14 ' ] ) ;
222+ expect ( _fn ( toolVersionFilePath ) ) . toEqual ( [ 'pypy3.10-7.3.19 ' ] ) ;
195223 }
196224 ) ;
197225
0 commit comments