@@ -31,8 +31,11 @@ pub struct GodotVersion {
31
31
pub fn parse_godot_version ( version_str : & str ) -> Result < GodotVersion , Box < dyn Error > > {
32
32
// Format of the string emitted by `godot --version`:
33
33
// https://github.com/godot-rust/gdext/issues/118#issuecomment-1465748123
34
+ // We assume that it's on a line of its own, but it may be surrounded by other lines.
34
35
let regex = Regex :: new (
35
- r#"(?x) # ignore whitespace and allow line comments (starting with `#`)
36
+ r#"(?xm)
37
+ # x: ignore whitespace and allow line comments (starting with `#`)
38
+ # m: multi-line mode, ^ and $ match start and end of line
36
39
^
37
40
(?P<major>\d+)
38
41
\.(?P<minor>\d+)
@@ -100,6 +103,13 @@ fn test_godot_versions() {
100
103
( "4.0.beta8.mono.custom_build.b28ddd918" , 4 , 0 , 0 , "beta8" , s ( "b28ddd918" ) ) ,
101
104
( "4.0.rc1.official.8843d9ad3" , 4 , 0 , 0 , "rc1" , s ( "8843d9ad3" ) ) ,
102
105
( "4.0.stable.arch_linux" , 4 , 0 , 0 , "stable" , None ) ,
106
+ // Output from 4.0.stable on MacOS in debug mode:
107
+ // https://github.com/godotengine/godot/issues/74906
108
+ ( "arguments
109
+ 0: /Users/runner/work/_temp/godot_bin/godot.macos.editor.dev.x86_64
110
+ 1: --version
111
+ Current path: /Users/runner/work/gdext/gdext/godot-core
112
+ 4.1.dev.custom_build.79454bfd3" , 4 , 1 , 0 , "dev" , s ( "79454bfd3" ) ) ,
103
113
] ;
104
114
105
115
let bad_versions = [
@@ -110,7 +120,8 @@ fn test_godot_versions() {
110
120
111
121
for ( full, major, minor, patch, status, custom_rev) in good_versions {
112
122
let expected = GodotVersion {
113
- full_string : full. to_owned ( ) ,
123
+ // Version line is last in every test at the moment.
124
+ full_string : full. lines ( ) . last ( ) . unwrap ( ) . to_owned ( ) ,
114
125
major,
115
126
minor,
116
127
patch,
0 commit comments