#!/usr/bin/env bash # shellcheck shell=bash source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" TEST_NAME="test_pkgpolicy" phoebus_test_setup # Default is balanced and a binary source is configured. config_set PACKAGE_POLICY "balanced" config_set FEATURES_BINPKG "yes" config_set BINHOST_URI "https://example.invalid/binpkgs" assert_eq "45" "$(pkgpolicy_compile_seconds app-editors/vim)" "known compile time (vim)" assert_eq "300" "$(pkgpolicy_compile_seconds dev-libs/unknown)" "unknown defaults to 300s" assert_eq "source" "$(pkgpolicy_decide app-editors/vim)" "cheap package compiles" assert_eq "binary" "$(pkgpolicy_decide www-client/firefox)" "huge package uses binary" assert_eq "source" "$(pkgpolicy_decide sys-kernel/gentoo-kernel)" "kernel always compiles" # policy overrides config_set PACKAGE_POLICY "source_first" assert_eq "source" "$(pkgpolicy_decide www-client/firefox)" "source_first compiles everything" config_set PACKAGE_POLICY "binary_first" assert_eq "binary" "$(pkgpolicy_decide app-editors/vim)" "binary_first prefers binaries" # history override config_set PACKAGE_POLICY "balanced" printf 'app-editors/vim\t7\t25\n' >"${STATE_DIR}/compile-times.tsv" assert_eq "7" "$(pkgpolicy_compile_seconds app-editors/vim)" "history overrides estimate" # no binary host -> source even in binary_first config_set BINHOST_URI "" config_set PACKAGE_POLICY "binary_first" assert_eq "source" "$(pkgpolicy_decide www-client/firefox)" "no binhost means compile" phoebus_test_report