-
-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathPlatformHelperTest.groovy
More file actions
72 lines (60 loc) · 2.47 KB
/
PlatformHelperTest.groovy
File metadata and controls
72 lines (60 loc) · 2.47 KB
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
package com.github.gradle.node.util
import spock.lang.Specification
import spock.lang.Unroll
class PlatformHelperTest extends Specification {
private Properties props
private PlatformHelper helper
def setup() {
this.props = new Properties()
PlatformHelper.INSTANCE = this.helper = new PlatformHelper(this.props)
}
@Unroll
def "check os and architecture for #osProp (#archProp)"() {
given:
this.props.setProperty("os.name", osProp)
this.props.setProperty("os.arch", archProp)
expect:
this.helper.getOsName() == osName
this.helper.getOsArch() == osArch
this.helper.isWindows() == isWindows
this.helper.isSupported() == isSupported
where:
osProp | archProp | osName | osArch | isWindows | isSupported
'Windows 8' | 'x86' | 'win' | 'x86' | true | true
'Windows 8' | 'x86_64' | 'win' | 'x64' | true | true
'Mac OS X' | 'x86' | 'darwin' | 'x86' | false | true
'Mac OS X' | 'x86_64' | 'darwin' | 'x64' | false | true
'Linux' | 'x86' | 'linux' | 'x86' | false | true
'Linux' | 'x86_64' | 'linux' | 'x64' | false | true
'Linux' | 'ppc64le' | 'linux' | 'ppc64le' | false | true
'SunOS' | 'x86' | 'sunos' | 'x86' | false | true
'SunOS' | 'x86_64' | 'sunos' | 'x64' | false | true
'FreeBSD' | 'amd64' | 'unsupported' | 'x64' | false | false
}
@Unroll
def "verify ARM handling #archProp (#unameProp)"() {
given:
this.props.setProperty("os.name", "Linux")
this.props.setProperty("os.arch", archProp)
this.props.setProperty("uname", unameProp)
expect:
this.helper.getOsName() == "linux"
this.helper.getOsArch() == osArch
where:
archProp | unameProp | osArch
'arm' | 'armv7l' | 'armv7l' // Raspberry Pi 3
'arm' | 'armv8l' | 'arm64'
'aarch32' | 'arm' | 'arm'
'aarch64' | 'arm64' | 'arm64'
'aarch64' | 'aarch64' | 'arm64'
'ppc64le' | 'ppc64le' | 'ppc64le'
}
def "throw exception if unsupported os"() {
given:
this.props.setProperty("os.name", 'Nonsense')
when:
this.helper.failOnUnsupportedOs()
then:
thrown(IllegalStateException)
}
}