From aa98085d6e85524bc668512f8bd01e528cb3d355 Mon Sep 17 00:00:00 2001 From: Deniz Mert Edincik Date: Sat, 11 Nov 2023 09:44:50 +0100 Subject: [PATCH] move blockchain helpers to separate package --- test/{ => helpers}/blockchain_helpers.cdc | 0 test/{ => helpers}/blockchain_helpers.go | 8 +++++--- test/test_framework_test.go | 4 +++- test/test_runner.go | 13 ++++++------- 4 files changed, 14 insertions(+), 11 deletions(-) rename test/{ => helpers}/blockchain_helpers.cdc (100%) rename test/{ => helpers}/blockchain_helpers.go (92%) diff --git a/test/blockchain_helpers.cdc b/test/helpers/blockchain_helpers.cdc similarity index 100% rename from test/blockchain_helpers.cdc rename to test/helpers/blockchain_helpers.cdc diff --git a/test/blockchain_helpers.go b/test/helpers/blockchain_helpers.go similarity index 92% rename from test/blockchain_helpers.go rename to test/helpers/blockchain_helpers.go index 796ca179..b3befde9 100644 --- a/test/blockchain_helpers.go +++ b/test/helpers/blockchain_helpers.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package test +package helpers import ( _ "embed" @@ -32,6 +32,8 @@ import ( //go:embed blockchain_helpers.cdc var BlockchainHelpers []byte +const BlockchainHelpersLocation = common.IdentifierLocation("BlockchainHelpers") + func BlockchainHelpersChecker() *sema.Checker { program, err := parser.ParseProgram( nil, @@ -73,8 +75,8 @@ func BlockchainHelpersChecker() *sema.Checker { BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return activation }, - AccessCheckMode: sema.AccessCheckModeStrict, - ImportHandler: importHandler, + AccessCheckMode: sema.AccessCheckModeStrict, + ImportHandler: importHandler, }, ) if err != nil { diff --git a/test/test_framework_test.go b/test/test_framework_test.go index 07453f4b..978c4b3e 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -23,6 +23,8 @@ import ( "fmt" "testing" + "github.com/onflow/cadence-tools/test/helpers" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -4762,7 +4764,7 @@ func TestBlockchainReset(t *testing.T) { func TestBlockchainHelpersChecker(t *testing.T) { t.Parallel() - checker := BlockchainHelpersChecker() + checker := helpers.BlockchainHelpersChecker() err := checker.Check() assert.NoError(t, err) } diff --git a/test/test_runner.go b/test/test_runner.go index 522eeab0..7d7c0cf7 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -28,6 +28,7 @@ import ( "github.com/onflow/flow-go/model/flow" + "github.com/onflow/cadence-tools/test/helpers" "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/runtime/ast" "github.com/onflow/cadence/runtime/common" @@ -59,8 +60,6 @@ const afterEachFunctionName = "afterEach" var testScriptLocation = common.NewScriptLocation(nil, []byte("test")) -const BlockchainHelpersLocation = common.IdentifierLocation("BlockchainHelpers") - var quotedLog = regexp.MustCompile("\"(.*)\"") type Results []Result @@ -454,7 +453,7 @@ func (r *TestRunner) initializeEnvironment() ( if r.coverageReport != nil { r.coverageReport.ExcludeLocation(stdlib.CryptoCheckerLocation) r.coverageReport.ExcludeLocation(stdlib.TestContractLocation) - r.coverageReport.ExcludeLocation(BlockchainHelpersLocation) + r.coverageReport.ExcludeLocation(helpers.BlockchainHelpersLocation) r.coverageReport.ExcludeLocation(testScriptLocation) ctx.CoverageReport = r.coverageReport } @@ -497,8 +496,8 @@ func (r *TestRunner) checkerImportHandler(ctx runtime.Context) sema.ImportHandle testChecker := stdlib.GetTestContractType().Checker elaboration = testChecker.Elaboration - case BlockchainHelpersLocation: - helpersChecker := BlockchainHelpersChecker() + case helpers.BlockchainHelpersLocation: + helpersChecker := helpers.BlockchainHelpersChecker() elaboration = helpersChecker.Elaboration default: @@ -628,8 +627,8 @@ func (r *TestRunner) interpreterImportHandler(ctx runtime.Context) interpreter.I testChecker := stdlib.GetTestContractType().Checker program = interpreter.ProgramFromChecker(testChecker) - case BlockchainHelpersLocation: - helpersChecker := BlockchainHelpersChecker() + case helpers.BlockchainHelpersLocation: + helpersChecker := helpers.BlockchainHelpersChecker() program = interpreter.ProgramFromChecker(helpersChecker) default: