diff --git a/cmd/ledgerutil/main.go b/cmd/ledgerutil/main.go index 55ab3f57966..037e14c6193 100644 --- a/cmd/ledgerutil/main.go +++ b/cmd/ledgerutil/main.go @@ -53,14 +53,14 @@ func main() { *outputDir, err = os.Getwd() if err != nil { fmt.Printf("%s%s\n", compareErrorMessage, err) - return + os.Exit(1) } } count, outputDirPath, err := ledgerutil.Compare(*snapshotPath1, *snapshotPath2, *outputDir, *firstDiffs) if err != nil { fmt.Printf("%s%s\n", compareErrorMessage, err) - return + os.Exit(1) } fmt.Print("\nSuccessfully compared snapshots. ") @@ -68,6 +68,7 @@ func main() { fmt.Println("Both snapshot public state and private state hashes were the same. No results were generated.") } else { fmt.Printf("Results saved to %s. Total differences found: %d\n", outputDirPath, count) + os.Exit(2) } } } diff --git a/cmd/ledgerutil/main_test.go b/cmd/ledgerutil/main_test.go index b62c1ab4a88..2076d272e06 100644 --- a/cmd/ledgerutil/main_test.go +++ b/cmd/ledgerutil/main_test.go @@ -38,7 +38,11 @@ func TestArguments(t *testing.T) { }, "one-snapshot": { exitCode: 1, - args: []string{"compare, snapshotDir1"}, + args: []string{"compare", "snapshotDir1"}, + }, + "invalid-snapshot-dirs": { + exitCode: 1, + args: []string{"compare", "/non-existent/snapshot1", "/non-existent/snapshot2"}, }, } diff --git a/docs/source/commands/ledgerutil.md b/docs/source/commands/ledgerutil.md index 31550ecb3b7..98b198ac691 100644 --- a/docs/source/commands/ledgerutil.md +++ b/docs/source/commands/ledgerutil.md @@ -47,6 +47,14 @@ Args: Second ledger snapshot directory. ``` +## Exit Status + +### ledgerutil compare + +- `0` if the snapshots are identical +- `2` if the snapshots are not identical +- `1` if an error occurs + ## Example Usage ### ledgerutil compare example diff --git a/docs/wrappers/ledgerutil_postscript.md b/docs/wrappers/ledgerutil_postscript.md index a58389b604e..53e44d7f241 100644 --- a/docs/wrappers/ledgerutil_postscript.md +++ b/docs/wrappers/ledgerutil_postscript.md @@ -1,3 +1,11 @@ +## Exit Status + +### ledgerutil compare + +- `0` if the snapshots are identical +- `2` if the snapshots are not identical +- `1` if an error occurs + ## Example Usage ### ledgerutil compare example