@@ -250,6 +250,16 @@ func TestGoldenFiles(t *testing.T) {
250250 t .Errorf ("Output does not match golden file with placeholders.\n Command: %s\n Expected:\n %s\n \n Got:\n %s" ,
251251 cmd , expected , actual )
252252 }
253+ } else if strings .Contains (expected , "<VERSION_PLACEHOLDER>" ) {
254+ // Match version output with placeholder
255+ // Replace the actual version in the output with the placeholder and compare
256+ actualNormalized := actual
257+ // Look for a line like 'rules version x.y.z' and replace the version with the placeholder
258+ actualNormalized = versionPlaceholderNormalize (actualNormalized )
259+ if actualNormalized != expected {
260+ t .Errorf ("Output does not match golden file with version placeholder.\n Command: %s\n Expected:\n %s\n \n Got:\n %s" ,
261+ cmd , expected , actual )
262+ }
253263 } else {
254264 // Standard equality check for other files
255265 if actual != expected {
@@ -261,6 +271,18 @@ func TestGoldenFiles(t *testing.T) {
261271 }
262272}
263273
274+ // versionPlaceholderNormalize replaces the version number in the version output with the placeholder
275+ func versionPlaceholderNormalize (s string ) string {
276+ lines := strings .Split (s , "\n " )
277+ for i , line := range lines {
278+ if strings .HasPrefix (line , "rules version " ) {
279+ // Replace everything after 'rules version '
280+ lines [i ] = "rules version <VERSION_PLACEHOLDER>"
281+ }
282+ }
283+ return strings .Join (lines , "\n " )
284+ }
285+
264286// copyFile copies a file from src to dst
265287func copyFile (src , dst string ) error {
266288 sourceFile , err := os .Open (src )
0 commit comments