No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

483 líneas
11 KiB

hace 10 años
hace 10 años
hace 10 años
hace 10 años
hace 10 años
hace 10 años
hace 10 años
hace 10 años
hace 10 años
hace 10 años
hace 10 años
  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 -n PYTHON_CONFIGURE_OPTS
  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. @test "yaml is installed for python" {
  51. cached_tarball "yaml-0.1.6"
  52. cached_tarball "Python-3.2.1"
  53. stub brew false
  54. stub_make_install
  55. stub_make_install
  56. install_fixture definitions/needs-yaml
  57. assert_success
  58. unstub make
  59. assert_build_log <<OUT
  60. yaml-0.1.6: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  61. yaml-0.1.6: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  62. make -j 2
  63. make install
  64. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  65. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  66. make -j 2
  67. make install
  68. OUT
  69. }
  70. @test "apply python patch before building" {
  71. cached_tarball "yaml-0.1.6"
  72. cached_tarball "Python-3.2.1"
  73. stub brew false
  74. stub_make_install
  75. stub_make_install
  76. stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
  77. TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <<<""
  78. assert_success
  79. unstub make
  80. unstub patch
  81. assert_build_log <<OUT
  82. yaml-0.1.6: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  83. yaml-0.1.6: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  84. make -j 2
  85. make install
  86. patch -p0 --force -i $TMP/python-patch.XXX
  87. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  88. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  89. make -j 2
  90. make install
  91. OUT
  92. }
  93. @test "apply python patch from git diff before building" {
  94. cached_tarball "yaml-0.1.6"
  95. cached_tarball "Python-3.2.1"
  96. stub brew false
  97. stub_make_install
  98. stub_make_install
  99. stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
  100. TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <<<"diff --git a/script.py"
  101. assert_success
  102. unstub make
  103. unstub patch
  104. assert_build_log <<OUT
  105. yaml-0.1.6: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  106. yaml-0.1.6: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  107. make -j 2
  108. make install
  109. patch -p1 --force -i $TMP/python-patch.XXX
  110. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  111. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  112. make -j 2
  113. make install
  114. OUT
  115. }
  116. @test "yaml is linked from Homebrew" {
  117. cached_tarball "Python-3.2.1"
  118. brew_libdir="$TMP/homebrew-yaml"
  119. mkdir -p "$brew_libdir"
  120. stub brew "--prefix libyaml : echo '$brew_libdir'" false
  121. stub_make_install
  122. install_fixture definitions/needs-yaml
  123. assert_success
  124. unstub brew
  125. unstub make
  126. assert_build_log <<OUT
  127. Python-3.2.1: CPPFLAGS="-I$brew_libdir/include -I${TMP}/install/include " LDFLAGS="-L$brew_libdir/lib -L${TMP}/install/lib "
  128. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  129. make -j 2
  130. make install
  131. OUT
  132. }
  133. @test "readline is linked from Homebrew" {
  134. cached_tarball "Python-3.2.1"
  135. readline_libdir="$TMP/homebrew-readline"
  136. mkdir -p "$readline_libdir"
  137. stub brew "--prefix readline : echo '$readline_libdir'"
  138. stub_make_install
  139. run_inline_definition <<DEF
  140. install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz"
  141. DEF
  142. assert_success
  143. unstub brew
  144. unstub make
  145. assert_build_log <<OUT
  146. Python-3.2.1: CPPFLAGS="-I$readline_libdir/include -I${TMP}/install/include " LDFLAGS="-L$readline_libdir/lib -L${TMP}/install/lib "
  147. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  148. make -j 2
  149. make install
  150. OUT
  151. }
  152. @test "readline is not linked from Homebrew when explicitly defined" {
  153. cached_tarball "Python-3.2.1"
  154. # python-build
  155. readline_libdir="$TMP/custom"
  156. mkdir -p "$readline_libdir/include/readline"
  157. touch "$readline_libdir/include/readline/rlconf.h"
  158. stub brew
  159. stub_make_install
  160. export PYTHON_CONFIGURE_OPTS="CPPFLAGS=-I$readline_libdir/include LDFLAGS=-L$readline_libdir/lib"
  161. run_inline_definition <<DEF
  162. install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz"
  163. DEF
  164. assert_success
  165. unstub brew
  166. unstub make
  167. assert_build_log <<OUT
  168. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  169. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib CPPFLAGS=-I$readline_libdir/include LDFLAGS=-L$readline_libdir/lib
  170. make -j 2
  171. make install
  172. OUT
  173. }
  174. @test "number of CPU cores defaults to 2" {
  175. cached_tarball "Python-3.2.1"
  176. # yyuu/pyenv#222
  177. stub uname '-s : echo Darwin'
  178. stub sw_vers '-productVersion : echo 10.10'
  179. stub uname '-s : echo Darwin'
  180. stub sysctl false
  181. stub_make_install
  182. export -n MAKE_OPTS
  183. run_inline_definition <<DEF
  184. install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz"
  185. DEF
  186. assert_success
  187. unstub uname
  188. unstub make
  189. assert_build_log <<OUT
  190. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  191. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  192. make -j 2
  193. make install
  194. OUT
  195. }
  196. @test "number of CPU cores is detected on Mac" {
  197. cached_tarball "Python-3.2.1"
  198. # yyuu/pyenv#222
  199. stub uname '-s : echo Darwin'
  200. stub sw_vers '-productVersion : echo 10.10'
  201. stub uname '-s : echo Darwin'
  202. stub sysctl '-n hw.ncpu : echo 4'
  203. stub_make_install
  204. export -n MAKE_OPTS
  205. run_inline_definition <<DEF
  206. install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz"
  207. DEF
  208. assert_success
  209. unstub uname
  210. unstub sysctl
  211. unstub make
  212. assert_build_log <<OUT
  213. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  214. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  215. make -j 4
  216. make install
  217. OUT
  218. }
  219. @test "number of CPU cores is detected on FreeBSD" {
  220. cached_tarball "Python-3.2.1"
  221. stub uname '-s : echo FreeBSD'
  222. stub sysctl '-n hw.ncpu : echo 1'
  223. stub_make_install
  224. # yyuu/pyenv#222
  225. stub uname '-s : echo FreeBSD'
  226. export -n MAKE_OPTS
  227. run_inline_definition <<DEF
  228. install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz"
  229. DEF
  230. assert_success
  231. unstub uname
  232. unstub sysctl
  233. unstub make
  234. assert_build_log <<OUT
  235. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  236. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  237. make -j 1
  238. make install
  239. OUT
  240. }
  241. @test "setting PYTHON_MAKE_INSTALL_OPTS to a multi-word string" {
  242. cached_tarball "Python-3.2.1"
  243. stub_make_install
  244. export PYTHON_MAKE_INSTALL_OPTS="DOGE=\"such wow\""
  245. run_inline_definition <<DEF
  246. install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz"
  247. DEF
  248. assert_success
  249. unstub make
  250. assert_build_log <<OUT
  251. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  252. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  253. make -j 2
  254. make install DOGE="such wow"
  255. OUT
  256. }
  257. @test "setting MAKE_INSTALL_OPTS to a multi-word string" {
  258. cached_tarball "Python-3.2.1"
  259. stub_make_install
  260. export MAKE_INSTALL_OPTS="DOGE=\"such wow\""
  261. run_inline_definition <<DEF
  262. install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz"
  263. DEF
  264. assert_success
  265. unstub make
  266. assert_build_log <<OUT
  267. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  268. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  269. make -j 2
  270. make install DOGE="such wow"
  271. OUT
  272. }
  273. @test "custom relative install destination" {
  274. export PYTHON_BUILD_CACHE_PATH="$FIXTURE_ROOT"
  275. cd "$TMP"
  276. install_fixture definitions/without-checksum ./here
  277. assert_success
  278. assert [ -x ./here/bin/package ]
  279. }
  280. @test "make on FreeBSD 9 defaults to gmake" {
  281. cached_tarball "Python-3.2.1"
  282. stub uname "-s : echo FreeBSD" "-r : echo 9.1"
  283. MAKE=gmake stub_make_install
  284. # yyuu/pyenv#222
  285. stub uname '-s : echo FreeBSD'
  286. MAKE= install_fixture definitions/vanilla-python
  287. assert_success
  288. unstub gmake
  289. unstub uname
  290. }
  291. @test "make on FreeBSD 10" {
  292. cached_tarball "Python-3.2.1"
  293. stub uname "-s : echo FreeBSD" "-r : echo 10.0-RELEASE"
  294. stub_make_install
  295. # yyuu/pyenv#222
  296. stub uname '-s : echo FreeBSD'
  297. MAKE= install_fixture definitions/vanilla-python
  298. assert_success
  299. unstub uname
  300. }
  301. @test "can use PYTHON_CONFIGURE to apply a patch" {
  302. cached_tarball "Python-3.2.1"
  303. executable "${TMP}/custom-configure" <<CONF
  304. #!$BASH
  305. apply -p1 -i /my/patch.diff
  306. exec ./configure "\$@"
  307. CONF
  308. stub apply 'echo apply "$@" >> build.log'
  309. stub_make_install
  310. export PYTHON_CONFIGURE="${TMP}/custom-configure"
  311. run_inline_definition <<DEF
  312. install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz"
  313. DEF
  314. assert_success
  315. unstub make
  316. unstub apply
  317. assert_build_log <<OUT
  318. apply -p1 -i /my/patch.diff
  319. Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
  320. Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
  321. make -j 2
  322. make install
  323. OUT
  324. }
  325. @test "copy strategy forces overwrite" {
  326. export PYTHON_BUILD_CACHE_PATH="$FIXTURE_ROOT"
  327. mkdir -p "$INSTALL_ROOT/bin"
  328. touch "$INSTALL_ROOT/bin/package"
  329. chmod -w "$INSTALL_ROOT/bin/package"
  330. install_fixture definitions/without-checksum
  331. assert_success
  332. run "$INSTALL_ROOT/bin/package" "world"
  333. assert_success "hello world"
  334. }
  335. @test "mruby strategy overwrites non-writable files" {
  336. # nop
  337. }
  338. @test "mruby strategy fetches rake if missing" {
  339. # nop
  340. }
  341. @test "rbx uses bundle then rake" {
  342. # nop
  343. }
  344. @test "fixes rbx binstubs" {
  345. # nop
  346. }
  347. @test "JRuby build" {
  348. # nop
  349. }
  350. @test "JRuby+Graal does not install launchers" {
  351. # nop
  352. }
  353. @test "JRuby Java 7 missing" {
  354. # nop
  355. }
  356. @test "JRuby Java is outdated" {
  357. # nop
  358. }
  359. @test "JRuby Java 7 up-to-date" {
  360. # nop
  361. }
  362. @test "non-writable TMPDIR aborts build" {
  363. export TMPDIR="${TMP}/build"
  364. mkdir -p "$TMPDIR"
  365. chmod -w "$TMPDIR"
  366. touch "${TMP}/build-definition"
  367. run python-build "${TMP}/build-definition" "$INSTALL_ROOT"
  368. assert_failure "python-build: TMPDIR=$TMPDIR is set to a non-accessible location"
  369. }
  370. @test "non-executable TMPDIR aborts build" {
  371. export TMPDIR="${TMP}/build"
  372. mkdir -p "$TMPDIR"
  373. chmod -x "$TMPDIR"
  374. touch "${TMP}/build-definition"
  375. run python-build "${TMP}/build-definition" "$INSTALL_ROOT"
  376. assert_failure "python-build: TMPDIR=$TMPDIR is set to a non-accessible location"
  377. }