File tree 2 files changed +54
-0
lines changed
2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # Run each tests/*.test.ts file separately to avoid account state persisting between tests
4
+ for file in ` ls tests/* .test.ts`
5
+ do
6
+ # convert file-name to FILE_NAME
7
+ declare -u env_flag
8
+ filename=$( basename -- " $file " )
9
+ filename=" ${filename% .test.* } "
10
+ env_flag=${filename// -/ _}
11
+
12
+ env $env_flag =1 bash -c ' anchor test --skip-build'
13
+ done
Original file line number Diff line number Diff line change
1
+ import {
2
+ ChainContext ,
3
+ Signer ,
4
+ signSendWait as ssw ,
5
+ } from "@wormhole-foundation/sdk" ;
6
+ import path from "path" ;
7
+
8
+ const TESTFILE_MATCH_PATTERN = / .t e s t .t s $ / ;
9
+
10
+ /**
11
+ * Skips test file execution if the corresponding environment variable is not set.
12
+ *
13
+ * eg:- To run `file-name.test.ts`, `FILE_NAME` environment variable should be set
14
+ */
15
+ export const handleTestSkip = ( filename : string ) => {
16
+ const testName = path . basename ( filename ) . replace ( TESTFILE_MATCH_PATTERN , "" ) ;
17
+ const envVar = testName . replaceAll ( "-" , "_" ) . toUpperCase ( ) ;
18
+ const shouldRun = process . env [ envVar ] ;
19
+ if ( ! shouldRun ) {
20
+ test . only ( "Skipping all tests" , ( ) => { } ) ;
21
+ }
22
+ } ;
23
+
24
+ export const signSendWait = async (
25
+ chain : ChainContext < any , any , any > ,
26
+ txs : AsyncGenerator < any > ,
27
+ signer : Signer ,
28
+ shouldLog = true ,
29
+ shouldThrow = false
30
+ ) => {
31
+ try {
32
+ await ssw ( chain , txs , signer ) ;
33
+ } catch ( e ) {
34
+ if ( shouldLog ) {
35
+ console . error ( e ) ;
36
+ }
37
+ if ( shouldThrow ) {
38
+ throw e ;
39
+ }
40
+ }
41
+ } ;
You can’t perform that action at this time.
0 commit comments