From f5edc93a194f5b4ab8b7dc265f00e5217c0f3c78 Mon Sep 17 00:00:00 2001 From: Schuyler Martin Date: Mon, 8 Apr 2024 08:18:49 -0600 Subject: [PATCH] Test files transform fix (#21) * Fixes `tests/files` -> `tests/files/recipe` transform - Patch operation that was being used was illegal. You can't move to a new path inside the existing path - Fixes patch operation in this transform - Adds regression tests to unit testing workload * Updated comment --- conda_recipe_manager/parser/recipe_parser.py | 19 +- tests/parser/test_recipe_parser.py | 14 ++ tests/test_aux_files/google-cloud-cpp.yaml | 187 ++++++++++++++++ .../new_format_google-cloud-cpp.yaml | 203 ++++++++++++++++++ 4 files changed, 421 insertions(+), 2 deletions(-) create mode 100644 tests/test_aux_files/google-cloud-cpp.yaml create mode 100644 tests/test_aux_files/new_format_google-cloud-cpp.yaml diff --git a/conda_recipe_manager/parser/recipe_parser.py b/conda_recipe_manager/parser/recipe_parser.py index b4a841d60..c3c7d09a5 100644 --- a/conda_recipe_manager/parser/recipe_parser.py +++ b/conda_recipe_manager/parser/recipe_parser.py @@ -877,9 +877,24 @@ def _comparison(n: Node) -> int: if not new_recipe.contains_value(test_path): continue - _patch_move_base_path(test_path, "/files", "/files/recipe") + # Moving `files` to `files/recipe` is not possible in a single `move` operation as a new path has to be + # created in the path being moved. + test_files_path = RecipeParser.append_to_path(test_path, "/files") + if new_recipe.contains_value(test_files_path): + test_files_value = new_recipe.get_value(test_files_path) + # TODO: Fix, replace does not work here, produces `- null`, Issue #20 + # _patch_and_log({"op": "replace", "path": test_files_path, "value": None}) + _patch_and_log({"op": "remove", "path": test_files_path}) + _patch_and_log({"op": "add", "path": test_files_path, "value": None}) + _patch_and_log( + { + "op": "add", + "path": RecipeParser.append_to_path(test_files_path, "/recipe"), + "value": test_files_value, + } + ) # Edge case: `/source_files` exists but `/files` does not - if new_recipe.contains_value(RecipeParser.append_to_path(test_path, "/source_files")): + elif new_recipe.contains_value(RecipeParser.append_to_path(test_path, "/source_files")): _patch_add_missing_path(test_path, "/files") _patch_move_base_path(test_path, "/source_files", "/files/source") diff --git a/tests/parser/test_recipe_parser.py b/tests/parser/test_recipe_parser.py index bde294b57..2bfdeb905 100644 --- a/tests/parser/test_recipe_parser.py +++ b/tests/parser/test_recipe_parser.py @@ -126,6 +126,7 @@ def test_loading_obj_in_list() -> None: "curl.yaml", # Complex, multi-output recipe "gsm-amzn2-aarch64.yaml", # Regression test: Contains `- '*'` string that failed to parse "pytest-pep8.yaml", + "google-cloud-cpp.yaml", ], ) def test_round_trip(file: str) -> None: @@ -366,6 +367,19 @@ def test_render_to_object_multi_output() -> None: "Required field missing: /about/license_url", ], ), + # Regression test: TODO + ( + "google-cloud-cpp.yaml", + [], + [ + "A non-list item had a selector at: /outputs/0/script", + "A non-list item had a selector at: /outputs/1/script", + "A non-list item had a selector at: /outputs/0/script", + "A non-list item had a selector at: /outputs/1/script", + "Required field missing: /about/description", + "Required field missing: /about/license_url", + ], + ), # TODO Complete: The `curl.yaml` test is far from perfect. It is very much a work in progress. # ( # "curl.yaml", diff --git a/tests/test_aux_files/google-cloud-cpp.yaml b/tests/test_aux_files/google-cloud-cpp.yaml new file mode 100644 index 000000000..ad330c407 --- /dev/null +++ b/tests/test_aux_files/google-cloud-cpp.yaml @@ -0,0 +1,187 @@ +{% set version = "2.22.0" %} + +package: + name: google-cloud-cpp-split + version: {{ version }} + +source: + url: https://github.com/googleapis/google-cloud-cpp/archive/v{{ version }}.tar.gz + sha256: 0c68782e57959c82e0c81def805c01460a042c1aae0c2feee905acaa2a2dc9bf + +build: + number: 1 + +requirements: + build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - cmake + - ninja + - libgrpc + - libprotobuf + - zlib # Needed by gRPC + host: + - libgoogle-cloud-devel =={{ version }} + - libabseil + - libcurl + - libgrpc + - libprotobuf + - openssl + - nlohmann_json + - zlib # Needed by gRPC + +outputs: + - name: libgoogle-cloud-all + script: install-libgoogle-cloud.sh # [unix] + script: install-libgoogle-cloud.bat # [win] + requirements: + build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - cmake + - ninja + host: + - libgoogle-cloud-devel =={{ version }} + - libgoogle-cloud-logging-devel =={{ version }} + - libabseil + - libgrpc + - libprotobuf + run: + # From the google-cloud-cpp-core feedstock + - libgoogle-cloud-oauth2 + - libgoogle-cloud-bigtable + - libgoogle-cloud-iam + - libgoogle-cloud-logging + - libgoogle-cloud-monitoring + - libgoogle-cloud-policytroubleshooter + - libgoogle-cloud-pubsub + - libgoogle-cloud-spanner + - libgoogle-cloud-storage + - libgoogle-cloud-trace + # From the google-cloud-cpp-bigquery feedstock + - libgoogle-cloud-bigquery + # From the google-cloud-cpp-compute feedstock + - libgoogle-cloud-compute + # From the google-cloud-cpp-ai feedstock + - libgoogle-cloud-aiplatform + - libgoogle-cloud-automl + - libgoogle-cloud-contentwarehouse + - libgoogle-cloud-discoveryengine + - libgoogle-cloud-dialogflow_es + - libgoogle-cloud-dialogflow_cx + - libgoogle-cloud-dlp + - libgoogle-cloud-documentai + - libgoogle-cloud-retail + - libgoogle-cloud-speech + - libgoogle-cloud-talent + test: + commands: + # We use `kms` as a canary. Any other feature could do the job. + # + # presence of shared library (unix) + - test -f $PREFIX/lib/libgoogle_cloud_cpp_kms.{{ version }}.dylib # [osx] + - test -f $PREFIX/lib/libgoogle_cloud_cpp_kms.so.{{ version }} # [linux] + # absence of static library (windows). It belongs only in devel package. + - if exist %LIBRARY_LIB%\google_cloud_cpp_kms.lib exit 1 # [win] + # absence of headers (they belong in devel package) + - test ! -f $PREFIX/include/google/cloud/kms/v1/ekm_client.h # [unix] + - if exist %LIBRARY_INC%\google\cloud\kms\v1\ekm_client.h exit 1 # [win] + # absence of metadata for CMake & pkgconfig (belongs in devel package) + - test ! -f $PREFIX/lib/pkgconfig/google_cloud_cpp_kms.pc # [unix] + - test ! -f $PREFIX/lib/cmake/google_cloud_cpp_kms/google_cloud_cpp_kms-config.cmake # [unix] + - if exist %LIBRARY_PREFIX%\\lib\\cmake\\google_cloud_cpp_kms\\google_cloud_cpp_kms-config.cmake exit 1 # [win] + - name: libgoogle-cloud-all-devel + script: install-libgoogle-cloud.sh # [unix] + script: install-libgoogle-cloud.bat # [win] + build: + run_exports: + - {{ pin_subpackage("libgoogle-cloud-all", max_pin="x.x") }} + requirements: + build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - cmake + - ninja + host: + - libgoogle-cloud-devel =={{ version }} + - libgoogle-cloud-logging-devel =={{ version }} + run: + - {{ pin_subpackage("libgoogle-cloud-all", exact=True) }} + # From the google-cloud-cpp-core feedstock + - libgoogle-cloud-devel =={{ version }} + - libgoogle-cloud-oauth2-devel + - libgoogle-cloud-bigtable-devel + - libgoogle-cloud-iam-devel + - libgoogle-cloud-logging-devel + - libgoogle-cloud-monitoring-devel + - libgoogle-cloud-policytroubleshooter-devel + - libgoogle-cloud-pubsub-devel + - libgoogle-cloud-spanner-devel + - libgoogle-cloud-storage-devel + - libgoogle-cloud-trace-devel + # From the google-cloud-cpp-bigquery feedstock + - libgoogle-cloud-bigquery-devel + # From the google-cloud-cpp-compute feedstock + - libgoogle-cloud-compute-devel + # From the google-cloud-cpp-ai feedstock + - libgoogle-cloud-aiplatform-devel + - libgoogle-cloud-automl-devel + - libgoogle-cloud-contentwarehouse-devel + - libgoogle-cloud-discoveryengine-devel + - libgoogle-cloud-dialogflow_es-devel + - libgoogle-cloud-dialogflow_cx-devel + - libgoogle-cloud-dlp-devel + - libgoogle-cloud-documentai-devel + - libgoogle-cloud-retail-devel + - libgoogle-cloud-speech-devel + - libgoogle-cloud-talent-devel + test: + commands: + # presence of headers (they belong in devel package) + - test -f $PREFIX/include/google/cloud/kms/ekm_client.h # [unix] + - if not exist %LIBRARY_INC%\google\cloud\kms\ekm_client.h exit 1 # [win] + # presence of static library (on Windows) + - if not exist %LIBRARY_LIB%\google_cloud_cpp_kms.lib exit 1 # [win] + # build an example + - ./run_test_feature.sh # [unix] + - ./run_test_feature.bat # [win] + requires: + - {{ compiler('cxx') }} + - cmake + - ninja + files: + - run_test_feature.sh + - run_test_feature.bat + source_files: + # We use `kms` as a canary. Any other feature could do the job. + - google/cloud/kms/quickstart/*.cc + - google/cloud/kms/quickstart/CMakeLists.txt + # compatibility wrapper for legacy all-in-one output + - name: google-cloud-cpp + build: + run_exports: + - {{ pin_subpackage("libgoogle-cloud-all", max_pin="x.x") }} + requirements: + host: + - {{ pin_subpackage("libgoogle-cloud-all-devel", exact=True) }} + run: + - {{ pin_subpackage("libgoogle-cloud-all-devel", exact=True) }} + test: + commands: + - echo no test needed + +about: + home: https://github.com/googleapis/google-cloud-cpp + license: Apache-2.0 + license_family: Apache + license_file: LICENSE + summary: Google Cloud Client Library for C++ + +extra: + feedstock-name: google-cloud-cpp + recipe-maintainers: + - coryan + - davidbrochart + - dbolduc + - h-vetinari + - xhochy diff --git a/tests/test_aux_files/new_format_google-cloud-cpp.yaml b/tests/test_aux_files/new_format_google-cloud-cpp.yaml new file mode 100644 index 000000000..10d922367 --- /dev/null +++ b/tests/test_aux_files/new_format_google-cloud-cpp.yaml @@ -0,0 +1,203 @@ +schema_version: 1 + +context: + version: 2.22.0 + +recipe: + name: google-cloud-cpp-split + version: ${{ version }} + +source: + url: https://github.com/googleapis/google-cloud-cpp/archive/v${{ version }}.tar.gz + sha256: 0c68782e57959c82e0c81def805c01460a042c1aae0c2feee905acaa2a2dc9bf + +build: + number: 1 + +requirements: + build: + - ${{ compiler('c') }} + - ${{ compiler('cxx') }} + - cmake + - ninja + - libgrpc + - libprotobuf + - zlib # Needed by gRPC + host: + - libgoogle-cloud-devel ==${{ version }} + - libabseil + - libcurl + - libgrpc + - libprotobuf + - openssl + - nlohmann_json + - zlib # Needed by gRPC + +outputs: + - package: + name: libgoogle-cloud-all + requirements: + build: + - ${{ compiler('c') }} + - ${{ compiler('cxx') }} + - cmake + - ninja + host: + - libgoogle-cloud-devel ==${{ version }} + - libgoogle-cloud-logging-devel ==${{ version }} + - libabseil + - libgrpc + - libprotobuf + run: + # From the google-cloud-cpp-core feedstock + - libgoogle-cloud-oauth2 + - libgoogle-cloud-bigtable + - libgoogle-cloud-iam + - libgoogle-cloud-logging + - libgoogle-cloud-monitoring + - libgoogle-cloud-policytroubleshooter + - libgoogle-cloud-pubsub + - libgoogle-cloud-spanner + - libgoogle-cloud-storage + - libgoogle-cloud-trace + # From the google-cloud-cpp-bigquery feedstock + - libgoogle-cloud-bigquery + # From the google-cloud-cpp-compute feedstock + - libgoogle-cloud-compute + # From the google-cloud-cpp-ai feedstock + - libgoogle-cloud-aiplatform + - libgoogle-cloud-automl + - libgoogle-cloud-contentwarehouse + - libgoogle-cloud-discoveryengine + - libgoogle-cloud-dialogflow_es + - libgoogle-cloud-dialogflow_cx + - libgoogle-cloud-dlp + - libgoogle-cloud-documentai + - libgoogle-cloud-retail + - libgoogle-cloud-speech + - libgoogle-cloud-talent + tests: + - python: + pip_check: false + - script: + - test -f $PREFIX/lib/libgoogle_cloud_cpp_kms.${{ version }}.dylib + - test -f $PREFIX/lib/libgoogle_cloud_cpp_kms.so.${{ version }} + - if: win + then: if exist %LIBRARY_LIB%\google_cloud_cpp_kms.lib exit 1 + - if: unix + then: test ! -f $PREFIX/include/google/cloud/kms/v1/ekm_client.h + - if: win + then: if exist %LIBRARY_INC%\google\cloud\kms\v1\ekm_client.h exit 1 + - if: unix + then: test ! -f $PREFIX/lib/pkgconfig/google_cloud_cpp_kms.pc + - if: unix + then: test ! -f $PREFIX/lib/cmake/google_cloud_cpp_kms/google_cloud_cpp_kms-config.cmake + - if: win + then: + - if exist %LIBRARY_PREFIX%\\lib\\cmake\\google_cloud_cpp_kms\\google_cloud_cpp_kms-config.cmake + - exit 1 + script: install-libgoogle-cloud.sh # [unix] + script: install-libgoogle-cloud.bat # [win] + - package: + name: libgoogle-cloud-all-devel + build: + requirements: + build: + - ${{ compiler('c') }} + - ${{ compiler('cxx') }} + - cmake + - ninja + host: + - libgoogle-cloud-devel ==${{ version }} + - libgoogle-cloud-logging-devel ==${{ version }} + run: + - ${{ pin_subpackage("libgoogle-cloud-all", exact=True) }} + # From the google-cloud-cpp-core feedstock + - libgoogle-cloud-devel ==${{ version }} + - libgoogle-cloud-oauth2-devel + - libgoogle-cloud-bigtable-devel + - libgoogle-cloud-iam-devel + - libgoogle-cloud-logging-devel + - libgoogle-cloud-monitoring-devel + - libgoogle-cloud-policytroubleshooter-devel + - libgoogle-cloud-pubsub-devel + - libgoogle-cloud-spanner-devel + - libgoogle-cloud-storage-devel + - libgoogle-cloud-trace-devel + # From the google-cloud-cpp-bigquery feedstock + - libgoogle-cloud-bigquery-devel + # From the google-cloud-cpp-compute feedstock + - libgoogle-cloud-compute-devel + # From the google-cloud-cpp-ai feedstock + - libgoogle-cloud-aiplatform-devel + - libgoogle-cloud-automl-devel + - libgoogle-cloud-contentwarehouse-devel + - libgoogle-cloud-discoveryengine-devel + - libgoogle-cloud-dialogflow_es-devel + - libgoogle-cloud-dialogflow_cx-devel + - libgoogle-cloud-dlp-devel + - libgoogle-cloud-documentai-devel + - libgoogle-cloud-retail-devel + - libgoogle-cloud-speech-devel + - libgoogle-cloud-talent-devel + run_exports: + - ${{ pin_subpackage("libgoogle-cloud-all", max_pin="x.x") }} + tests: + - python: + pip_check: false + - files: + recipe: + - run_test_feature.sh + - run_test_feature.bat + source: + - google/cloud/kms/quickstart/*.cc + - google/cloud/kms/quickstart/CMakeLists.txt + requirements: + run: + - ${{ compiler('cxx') }} + - cmake + - ninja + script: + - if: unix + then: test -f $PREFIX/include/google/cloud/kms/ekm_client.h + - if: win + then: if not exist %LIBRARY_INC%\google\cloud\kms\ekm_client.h exit 1 + - if: win + then: if not exist %LIBRARY_LIB%\google_cloud_cpp_kms.lib exit 1 + - if: unix + then: ./run_test_feature.sh + - if: win + then: ./run_test_feature.bat + script: install-libgoogle-cloud.sh # [unix] + script: install-libgoogle-cloud.bat # [win] + # compatibility wrapper for legacy all-in-one output + - package: + name: google-cloud-cpp + build: + requirements: + host: + - ${{ pin_subpackage("libgoogle-cloud-all-devel", exact=True) }} + run: + - ${{ pin_subpackage("libgoogle-cloud-all-devel", exact=True) }} + run_exports: + - ${{ pin_subpackage("libgoogle-cloud-all", max_pin="x.x") }} + tests: + - python: + pip_check: false + - script: + - echo no test needed + +about: + license: Apache-2.0 + license_file: LICENSE + summary: Google Cloud Client Library for C++ + homepage: https://github.com/googleapis/google-cloud-cpp + +extra: + feedstock-name: google-cloud-cpp + recipe-maintainers: + - coryan + - davidbrochart + - dbolduc + - h-vetinari + - xhochy