#!/usr/bin/env bats load 'helpers/utils' setup() { # Setup the environment for the test; this should override $HOME too omni_setup 3>&- setup_omni_config 3>&- # Add one repository setup_git_dir "git/github.com/test1org/test1repo" "git@github.com:test1org/test1repo.git" # Change directory to the repository cd "git/github.com/test1org/test1repo" } teardown() { check_commands } add_asdf_python_calls() { version="latest" fallback_version= plugin_installed=false installed=false others_installed=false venv=true cache_versions=false list_versions=true upgrade=false no_upgrade_installed=false for arg in "$@"; do case $arg in version=*) version="${arg#version=}" shift ;; fallback_version=*) fallback_version="${arg#fallback_version=}" shift ;; plugin_installed=*) plugin_installed="${arg#plugin_installed=}" shift ;; installed=*) installed="${arg#installed=}" shift ;; others_installed=*) others_installed="${arg#others_installed=}" shift ;; venv=*) venv="${arg#venv=}" shift ;; cache_versions=*) cache_versions="${arg#cache_versions=}" shift ;; list_versions=*) list_versions="${arg#list_versions=}" shift ;; upgrade=*) upgrade="${arg#upgrade=}" shift ;; no_upgrade_installed=*) no_upgrade_installed="${arg#no_upgrade_installed=}" shift ;; *) echo "Unknown argument: $arg" return 1 ;; esac done if [ "$version" = "latest" ]; then version="3.12.3" fi if [ "$cache_versions" = "true" ] || [ "$cache_versions" = "expired" ]; then if [ "$cache_versions" = "true" ]; then date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") else # This allows to support GNU date but also BSD date date=$(date -u +"%Y-%m-%dT%H:%M:%SZ" -d "300 days ago" 2>/dev/null || date -u -v-300d +"%Y-%m-%dT%H:%M:%SZ") fi mkdir -p "${HOME}/.cache/omni" perl -pe 's/{{ UPDATED_AT }}/'"${date}"'/g' "${PROJECT_DIR}/tests/fixtures/asdf_operation_cache.json" > "${HOME}/.cache/omni/asdf_operation.json" fi add_command asdf update if [ "$plugin_installed" = "true" ]; then add_command asdf plugin list add_command asdf plugin add python else add_command asdf plugin list < {}; mkShell { buildInputs = [ bzip2 gawk gcc gdbm gnumake gnused libffi ncurses openssl pkg-config readline sqlite xz zlib ]; }' add_command "${nix[@]}" build --print-out-paths --out-link "regex:${HOME}/\.local/share/omni/wd/.*/nix/profile-pkgs-.*" "regex:${tmpdir}/omni_up_nix\..*/profile" < "\$out_link" } EOF } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies (other versions installed)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies and call pip (single requirements file)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies and call pip (multiple requirements file)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies (already installed)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies (already installed + other versions)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies (plugin already installed)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies (install fail fallback to matching installed version)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies (cache versions hit)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies (cache versions expired)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies (cache versions expired but list versions fail)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) using brew for dependencies (cache versions expired but plugin update fail)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) with upgrade configured for the python version" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) with upgrade configured at the work directory level" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) with upgrade configured as a command-line parameter" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) with upgrade disabled and only an older major installed" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (2) with upgrade disabled and a version 2 installed" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (latest) with upgrade disabled and the current major installed" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (3) with upgrade disabled and a version 3 installed" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (*) using brew for dependencies" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (3.11.6) using brew for dependencies" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (>=3.10, <3.11) using brew for dependencies" { cat > .omni.yaml <=3.10, <3.11" EOF add_brew_python_calls add_asdf_python_calls version=3.10.14 run omni up --trust 3>&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (2.6.x || >3.10.12 <=3.11.2) using brew for dependencies" { cat > .omni.yaml <3.10.12 <=3.11.2" EOF add_brew_python_calls add_asdf_python_calls version=3.11.2 run omni up --trust 3>&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (~3.11.6) using brew for dependencies" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (3.11.x) using brew for dependencies" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (3.11) using brew for dependencies" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (2) using brew for dependencies (install fail does not fallback when no matching version installed)" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 1 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (2) using brew for dependencies" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:brew @test "omni up python operation (^2.5.2) using brew for dependencies" { cat > .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] } # bats test_tags=omni:up,omni:up:python,omni:up:python:nix @test "omni up python operation (latest) using nix for dependencies" { cat >> ~/.config/omni/config.yaml < .omni.yaml <&- echo "STATUS: $status" echo "OUTPUT: $output" [ "$status" -eq 0 ] }