forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
164 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package directories | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
const ( | ||
e2eDir = "e2e" | ||
|
||
// DefaultGenesisExportPath is the default path to which Genesis debug files will be exported to. | ||
DefaultGenesisExportPath = "diagnostics/genesis.json" | ||
) | ||
|
||
// E2E finds the e2e directory above the test. | ||
func E2E(t *testing.T) (string, error) { | ||
t.Helper() | ||
|
||
wd, err := os.Getwd() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
const maxAttempts = 100 | ||
count := 0 | ||
for ; !strings.HasSuffix(wd, e2eDir) || count > maxAttempts; wd = path.Dir(wd) { | ||
count++ | ||
} | ||
|
||
// arbitrary value to avoid getting stuck in an infinite loop if this is called | ||
// in a context where the e2e directory does not exist. | ||
if count > maxAttempts { | ||
return "", fmt.Errorf("unable to find e2e directory after %d tries", maxAttempts) | ||
} | ||
|
||
return wd, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters