]> Cypherpunks.ru repositories - goredo.git/commitdiff
Warn simultaneous ifcreate/ifchange usage v1.20.0
authorSergey Matveev <stargrave@stargrave.org>
Fri, 19 Nov 2021 11:08:07 +0000 (14:08 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 19 Nov 2021 11:09:04 +0000 (14:09 +0300)
doc/news.texi
run.go
t/goredo-both-ifcreate-ifchange.t [new file with mode: 0755]
usage.go

index 4f5ab5b437009779190e60a6f99812feeb676509..d74791e02414db33136bde1a97aeb5815ac0c8eb 100644 (file)
@@ -1,6 +1,14 @@
 @node News
 @unnumbered News
 
 @node News
 @unnumbered News
 
+@anchor{Release 1_20_0}
+@section Release 1.20.0
+@itemize
+@item
+    Print warning message if both ifcreate and ifchange records were
+    discovered after the target is done.
+@end itemize
+
 @anchor{Release 1_19_0}
 @section Release 1.19.0
 @itemize
 @anchor{Release 1_19_0}
 @section Release 1.19.0
 @itemize
diff --git a/run.go b/run.go
index a6401480d032f2b3c63536f9922084637942ac1f..0b77d499613f5549704b528fbfff49b440282ebd 100644 (file)
--- a/run.go
+++ b/run.go
@@ -731,6 +731,26 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
                                goto Finish
                        }
                }
                                goto Finish
                        }
                }
+
+               // Post-commit .rec sanitizing
+               fdDep.Close()
+               if fdDepR, err := os.Open(fdDepPath); err == nil {
+                       depInfo, err := depRead(fdDepR)
+                       fdDepR.Close()
+                       if err != nil {
+                               goto Finish
+                       }
+                       ifchangeSeen := make(map[string]struct{}, len(depInfo.ifchanges))
+                       for _, dep := range depInfo.ifchanges {
+                               ifchangeSeen[dep["Target"]] = struct{}{}
+                       }
+                       for _, dep := range depInfo.ifcreates {
+                               if _, exists := ifchangeSeen[dep]; exists {
+                                       tracef(CWarn, "simultaneous ifcreate and ifchange records: %s", tgt)
+                               }
+                       }
+               }
+
        Finish:
                runErr.Err = err
                errs <- runErr
        Finish:
                runErr.Err = err
                errs <- runErr
diff --git a/t/goredo-both-ifcreate-ifchange.t b/t/goredo-both-ifcreate-ifchange.t
new file mode 100755 (executable)
index 0000000..e269fb4
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+testname=`basename "$0"`
+test_description="Check that warning exists when using both ifcreate/ifchange"
+. $SHARNESS_TEST_SRCDIR/sharness.sh
+export REDO_TOP_DIR="`pwd`" REDO_NO_PROGRESS=1
+
+touch src
+echo redo-ifchange src > tgt.do
+echo redo-ifcreate src >> tgt.do
+redo tgt 2>2
+
+test_expect_success "warn exists" 'grep -q "simultaneous ifcreate and ifchange" 2'
+
+test_done
index 7de522f6c0aca1855cba15b7f9ae82ab41dc2ecc..428c9bc199a9bda724453b10f5c374a1b305bdee 100644 (file)
--- a/usage.go
+++ b/usage.go
@@ -24,7 +24,7 @@ import (
 )
 
 const (
 )
 
 const (
-       Version  = "1.19.0"
+       Version  = "1.20.0"
        Warranty = `Copyright (C) 2020-2021 Sergey Matveev
 
 This program is free software: you can redistribute it and/or modify
        Warranty = `Copyright (C) 2020-2021 Sergey Matveev
 
 This program is free software: you can redistribute it and/or modify