Skip to content

Commit

Permalink
Test files transform fix (#21)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
schuylermartin45 authored Apr 8, 2024
1 parent a84be85 commit f5edc93
Show file tree
Hide file tree
Showing 4 changed files with 421 additions and 2 deletions.
19 changes: 17 additions & 2 deletions conda_recipe_manager/parser/recipe_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
14 changes: 14 additions & 0 deletions tests/parser/test_recipe_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand Down
187 changes: 187 additions & 0 deletions tests/test_aux_files/google-cloud-cpp.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit f5edc93

Please sign in to comment.