File: definitions.bats

package info (click to toggle)
pyenv 2.5.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 8,264 kB
  • sloc: sh: 4,722; python: 402; makefile: 76; ansic: 60
file content (100 lines) | stat: -rw-r--r-- 2,655 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bats

load test_helper
NUM_DEFINITIONS="$(find "$BATS_TEST_DIRNAME"/../share/python-build -maxdepth 1 -type f | wc -l)"

@test "list built-in definitions" {
  run python-build --definitions
  assert_success
  assert_output_contains "2.7.8"
  assert_output_contains "jython-2.5.3"
  assert [ "${#lines[*]}" -eq "$NUM_DEFINITIONS" ]
}

@test "custom PYTHON_BUILD_ROOT: nonexistent" {
  export PYTHON_BUILD_ROOT="$TMP"
  refute [ -e "${PYTHON_BUILD_ROOT}/share/python-build" ]
  run python-build --definitions
  assert_success ""
}

@test "custom PYTHON_BUILD_ROOT: single definition" {
  export PYTHON_BUILD_ROOT="$TMP"
  mkdir -p "${PYTHON_BUILD_ROOT}/share/python-build"
  touch "${PYTHON_BUILD_ROOT}/share/python-build/2.7.8-test"
  run python-build --definitions
  assert_success "2.7.8-test"
}

@test "one path via PYTHON_BUILD_DEFINITIONS" {
  export PYTHON_BUILD_DEFINITIONS="${TMP}/definitions"
  mkdir -p "$PYTHON_BUILD_DEFINITIONS"
  touch "${PYTHON_BUILD_DEFINITIONS}/2.7.8-test"
  run python-build --definitions
  assert_success
  assert_output_contains "2.7.8-test"
  assert [ "${#lines[*]}" -eq "$((NUM_DEFINITIONS + 1))" ]
}

@test "multiple paths via PYTHON_BUILD_DEFINITIONS" {
  export PYTHON_BUILD_DEFINITIONS="${TMP}/definitions:${TMP}/other"
  mkdir -p "${TMP}/definitions"
  touch "${TMP}/definitions/2.7.8-test"
  mkdir -p "${TMP}/other"
  touch "${TMP}/other/3.4.2-test"
  run python-build --definitions
  assert_success
  assert_output_contains "2.7.8-test"
  assert_output_contains "3.4.2-test"
  assert [ "${#lines[*]}" -eq "$((NUM_DEFINITIONS + 2))" ]
}

@test "installing nonexistent definition" {
  run python-build "nonexistent" "${TMP}/install"
  assert [ "$status" -eq 2 ]
  assert_output "python-build: definition not found: nonexistent"
}

@test "sorting Python versions" {
  export PYTHON_BUILD_ROOT="$TMP"
  mkdir -p "${PYTHON_BUILD_ROOT}/share/python-build"
  expected="2.7-dev
2.7
2.7.1
2.7.2
2.7.3
3.4.0
3.4-dev
3.4.1
3.4.2
jython-dev
jython-2.5.0
jython-2.5-dev
jython-2.5.1
jython-2.5.2
jython-2.5.3
jython-2.5.4-rc1
jython-2.7-beta1
jython-2.7-beta2
jython-2.7-beta3"
  for ver in "$expected"; do
    touch "${PYTHON_BUILD_ROOT}/share/python-build/$ver"
  done
  run python-build --definitions
  assert_success "$expected"
}

@test "removing duplicate Python versions" {
  export PYTHON_BUILD_ROOT="$TMP"
  export PYTHON_BUILD_DEFINITIONS="${PYTHON_BUILD_ROOT}/share/python-build"
  mkdir -p "$PYTHON_BUILD_DEFINITIONS"
  touch "${PYTHON_BUILD_DEFINITIONS}/2.7.8"
  touch "${PYTHON_BUILD_DEFINITIONS}/3.4.2"

  run python-build --definitions
  assert_success
  assert_output <<OUT
2.7.8
3.4.2
OUT
}