@@ -710,6 +710,41 @@ describe('setup-go', () => {
710710 expect ( im . makeSemver ( '1.13.1' ) ) . toBe ( '1.13.1' ) ;
711711 } ) ;
712712
713+ describe ( 'normalizeVersionSpec' , ( ) => {
714+ it ( 'converts Go-style prerelease to semver format' , ( ) => {
715+ expect ( im . normalizeVersionSpec ( '1.14rc1' ) ) . toBe ( '1.14.0-rc.1' ) ;
716+ expect ( im . normalizeVersionSpec ( '1.14beta1' ) ) . toBe ( '1.14.0-beta.1' ) ;
717+ expect ( im . normalizeVersionSpec ( '1.21rc2' ) ) . toBe ( '1.21.0-rc.2' ) ;
718+ } ) ;
719+
720+ it ( 'preserves range prefixes when converting' , ( ) => {
721+ expect ( im . normalizeVersionSpec ( '^1.14rc1' ) ) . toBe ( '^1.14.0-rc.1' ) ;
722+ expect ( im . normalizeVersionSpec ( '~1.14beta1' ) ) . toBe ( '~1.14.0-beta.1' ) ;
723+ expect ( im . normalizeVersionSpec ( '>=1.14rc1' ) ) . toBe ( '>=1.14.0-rc.1' ) ;
724+ expect ( im . normalizeVersionSpec ( '>1.14rc1' ) ) . toBe ( '>1.14.0-rc.1' ) ;
725+ expect ( im . normalizeVersionSpec ( '<=1.14rc1' ) ) . toBe ( '<=1.14.0-rc.1' ) ;
726+ expect ( im . normalizeVersionSpec ( '<1.14rc1' ) ) . toBe ( '<1.14.0-rc.1' ) ;
727+ expect ( im . normalizeVersionSpec ( '=1.14rc1' ) ) . toBe ( '=1.14.0-rc.1' ) ;
728+ } ) ;
729+
730+ it ( 'preserves versions without Go-style prerelease' , ( ) => {
731+ expect ( im . normalizeVersionSpec ( '1.13' ) ) . toBe ( '1.13' ) ;
732+ expect ( im . normalizeVersionSpec ( '1.13.7' ) ) . toBe ( '1.13.7' ) ;
733+ expect ( im . normalizeVersionSpec ( '^1.13.6' ) ) . toBe ( '^1.13.6' ) ;
734+ expect ( im . normalizeVersionSpec ( '>=1.13' ) ) . toBe ( '>=1.13' ) ;
735+ } ) ;
736+
737+ it ( 'preserves already valid semver prerelease format' , ( ) => {
738+ expect ( im . normalizeVersionSpec ( '1.14.0-rc.1' ) ) . toBe ( '1.14.0-rc.1' ) ;
739+ expect ( im . normalizeVersionSpec ( '^1.14.0-beta.1' ) ) . toBe ( '^1.14.0-beta.1' ) ;
740+ } ) ;
741+
742+ it ( 'does not match false positives like "traced"' , ( ) => {
743+ // "traced" contains "rc" but should not be treated as prerelease
744+ expect ( im . normalizeVersionSpec ( '1.13traced' ) ) . toBe ( '1.13traced' ) ;
745+ } ) ;
746+ } ) ;
747+
713748 describe ( 'check-latest flag' , ( ) => {
714749 it ( "use local version and don't check manifest if check-latest is not specified" , async ( ) => {
715750 os . platform = 'linux' ;
0 commit comments