Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

140 lignes
3.2 KiB

  1. #!/usr/bin/env bats
  2. load test_helper
  3. export PYTHON_BUILD_CACHE_PATH="$TMP/cache"
  4. export MAKE=make
  5. export MAKE_OPTS="-j 2"
  6. export CC=cc
  7. export TMP_FIXTURES="$TMP/fixtures"
  8. setup() {
  9. mkdir -p "$INSTALL_ROOT"
  10. stub md5 false
  11. stub curl false
  12. }
  13. executable() {
  14. local file="$1"
  15. mkdir -p "${file%/*}"
  16. cat > "$file"
  17. chmod +x "$file"
  18. }
  19. cached_tarball() {
  20. mkdir -p "$PYTHON_BUILD_CACHE_PATH"
  21. pushd "$PYTHON_BUILD_CACHE_PATH" >/dev/null
  22. tarball "$@"
  23. popd >/dev/null
  24. }
  25. tarball() {
  26. local name="$1"
  27. local path="$PWD/$name"
  28. local configure="$path/configure"
  29. shift 1
  30. executable "$configure" <<OUT
  31. #!$BASH
  32. echo "$name: CPPFLAGS=\\"\$CPPFLAGS\\" LDFLAGS=\\"\$LDFLAGS\\"" >> build.log
  33. echo "$name: \$@" \${PYTHONOPT:+PYTHONOPT=\$PYTHONOPT} >> build.log
  34. OUT
  35. for file; do
  36. mkdir -p "$(dirname "${path}/${file}")"
  37. touch "${path}/${file}"
  38. done
  39. tar czf "${path}.tar.gz" -C "${path%/*}" "$name"
  40. }
  41. stub_make_install() {
  42. stub "$MAKE" \
  43. " : echo \"$MAKE \$@\" >> build.log" \
  44. "install : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
  45. }
  46. assert_build_log() {
  47. run cat "$INSTALL_ROOT/build.log"
  48. assert_output
  49. }
  50. install_patch() {
  51. local name="$1"
  52. local patch="$2"
  53. [ -n "$patch" ] || patch="python.patch"
  54. mkdir -p "${TMP_FIXTURES}/${name%/*}/patches/${name##*/}/${patch%/*}"
  55. cat > "${TMP_FIXTURES}/${name%/*}/patches/${name##*/}/${patch}"
  56. }
  57. install_tmp_fixture() {
  58. local args
  59. while [ "${1#-}" != "$1" ]; do
  60. args="$args $1"
  61. shift 1
  62. done
  63. local name="$1"
  64. local destination="$2"
  65. [ -n "$destination" ] || destination="$INSTALL_ROOT"
  66. # Copy fixture to temporary path
  67. mkdir -p "${TMP_FIXTURES}/${name%/*}"
  68. cp "${FIXTURE_ROOT}/${name}" "${TMP_FIXTURES}/${name}"
  69. run python-build $args "$TMP_FIXTURES/$name" "$destination"
  70. }
  71. @test "apply built-in python patch before building" {
  72. cached_tarball "Python-3.2.1"
  73. stub brew false
  74. stub_make_install
  75. stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
  76. echo | install_patch definitions/vanilla-python "Python-3.2.1/empty.patch"
  77. TMPDIR="$TMP" install_tmp_fixture definitions/vanilla-python < /dev/null
  78. assert_success
  79. assert_build_log <<OUT
  80. patch -p0 --force -i $TMP/python-patch.XXX
  81. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  82. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  83. make -j 2
  84. make install
  85. OUT
  86. unstub make
  87. unstub patch
  88. }
  89. @test "apply built-in python patches should be sorted by its name" {
  90. cached_tarball "Python-3.2.1"
  91. stub brew false
  92. stub_make_install
  93. stub patch ' : for arg; do [[ "$arg" == "-"* ]] || sed -e "s/^/patch: /" "$arg"; done >> build.log'
  94. echo "foo" | install_patch definitions/vanilla-python "Python-3.2.1/foo.patch"
  95. echo "bar" | install_patch definitions/vanilla-python "Python-3.2.1/bar.patch"
  96. echo "baz" | install_patch definitions/vanilla-python "Python-3.2.1/baz.patch"
  97. TMPDIR="$TMP" install_tmp_fixture definitions/vanilla-python < /dev/null
  98. assert_success
  99. assert_build_log <<OUT
  100. patch: bar
  101. patch: baz
  102. patch: foo
  103. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  104. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  105. make -j 2
  106. make install
  107. OUT
  108. unstub make
  109. unstub patch
  110. }