github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/tae/db/test/compatibility/all_test.go (about)

     1  // Copyright 2021 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package compatibility
    16  
    17  import (
    18  	"os"
    19  	"testing"
    20  
    21  	"github.com/stretchr/testify/require"
    22  )
    23  
    24  func runPrepareCase(prepareCase PrepareCase, t *testing.T) {
    25  	t.Logf("Prepare case: [%s: %s]", prepareCase.name, prepareCase.desc)
    26  	prepareCase.prepareFn(
    27  		prepareCase, t,
    28  	)
    29  }
    30  
    31  func runAllPrepare(t *testing.T) {
    32  	t.Log("Run all compatibility prepare cases")
    33  	err := InitPrepareEnv()
    34  	require.NoError(t, err)
    35  	for _, prepareCase := range PrepareCases {
    36  		runPrepareCase(prepareCase, t)
    37  	}
    38  }
    39  
    40  func runTestCase(testCase TestCase, t *testing.T) {
    41  	t.Logf("Execute case: [%s: %s]", testCase.name, testCase.desc)
    42  	testCase.testFn(
    43  		testCase, t,
    44  	)
    45  }
    46  
    47  func runAllTestCase(t *testing.T) {
    48  	t.Log("Run all compatibility test cases")
    49  	err := EnsurePrepareEnvOK()
    50  	require.NoError(t, err)
    51  	err = InitExecuteEnv()
    52  	require.NoError(t, err)
    53  	for _, testCase := range TestCases {
    54  		runTestCase(testCase, t)
    55  	}
    56  }
    57  
    58  func TestAll(t *testing.T) {
    59  	prepareEnv := os.Getenv("PREPCOMP")
    60  	execEnv := os.Getenv("EXECCOMP")
    61  	if prepareEnv == "false" && execEnv == "false" {
    62  		t.Skip("skip compatibility test")
    63  	} else if prepareEnv == "true" {
    64  		runAllPrepare(t)
    65  	} else if execEnv == "true" {
    66  		runAllTestCase(t)
    67  	} else {
    68  		runAllPrepare(t)
    69  		runAllTestCase(t)
    70  	}
    71  }