From fe3500c999b958b27d4216a691470d4c0e0b7738 Mon Sep 17 00:00:00 2001 From: aceforeverd Date: Fri, 28 Jun 2024 14:46:27 +0000 Subject: [PATCH] refactor: rm SQL_CASE_BASE_DIR --- hybridse/CMakeLists.txt | 6 ++++++ hybridse/src/case/sql_case.cc | 11 ++--------- hybridse/src/case/test_cfg.h.in | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 hybridse/src/case/test_cfg.h.in diff --git a/hybridse/CMakeLists.txt b/hybridse/CMakeLists.txt index 6640c5b9cd5..6a9dfeaf0a9 100644 --- a/hybridse/CMakeLists.txt +++ b/hybridse/CMakeLists.txt @@ -125,6 +125,12 @@ configure_file( "${PROJECT_SOURCE_DIR}/src/version.h.in" "${PROJECT_SOURCE_DIR}/src/hybridse_version.h" ) + +configure_file( + "${PROJECT_SOURCE_DIR}/src/case/test_cfg.h.in" + "${PROJECT_SOURCE_DIR}/src/case/test_cfg.h" +) + if (DEFINED ENV{CI}) # suppress useless maven log (e.g download log) on CI environment set(MAVEN_FLAGS --batch-mode) diff --git a/hybridse/src/case/sql_case.cc b/hybridse/src/case/sql_case.cc index ccb712bbdf9..a92a7c9028e 100644 --- a/hybridse/src/case/sql_case.cc +++ b/hybridse/src/case/sql_case.cc @@ -35,6 +35,7 @@ #include "glog/logging.h" #include "node/sql_node.h" #include "plan/plan_api.h" +#include "case/test_cfg.h" #include "vm/engine.h" #include "zetasql/parser/parser.h" #include "planv2/ast_node_converter.h" @@ -1758,15 +1759,7 @@ std::set SqlCase::HYBRIDSE_LEVEL() { } std::string SqlCase::SqlCaseBaseDir() { - char* value = getenv("SQL_CASE_BASE_DIR"); - if (value != nullptr) { - return std::string(value); - } - value = getenv("YAML_CASE_BASE_DIR"); - if (value != nullptr) { - return std::string(value); - } - return ""; + return SQL_CASE_BASE_DIR; } absl::StatusOr> ExtractInsertRow(vm::HybridSeJitWrapper* jit, absl::string_view insert, diff --git a/hybridse/src/case/test_cfg.h.in b/hybridse/src/case/test_cfg.h.in new file mode 100644 index 00000000000..76709fa9af8 --- /dev/null +++ b/hybridse/src/case/test_cfg.h.in @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2024 OpenMLDB Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HYBRIDSE_SRC_CASE_TEST_CFG_H_ +#define HYBRIDSE_SRC_CASE_TEST_CFG_H_ + +#define SQL_CASE_BASE_DIR "${CMAKE_SOURCE_DIR}" + +#endif // HYBRIDSE_SRC_CASE_TEST_CFG_H_