Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
e218266a
Commit
e218266a
authored
8 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Convert Mach-O test to spec.
parent
e98b623b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/test/os/mac/mach_spec.rb
+198
-0
198 additions, 0 deletions
Library/Homebrew/test/os/mac/mach_spec.rb
Library/Homebrew/test/os/mac/mach_test.rb
+0
-211
0 additions, 211 deletions
Library/Homebrew/test/os/mac/mach_test.rb
with
198 additions
and
211 deletions
Library/Homebrew/test/os/mac/mach_spec.rb
0 → 100644
+
198
−
0
View file @
e218266a
describe
"Mach-O Pathname tests"
do
specify
"fat dylib"
do
pn
=
dylib_path
(
"fat"
)
expect
(
pn
).
to
be_universal
expect
(
pn
).
not_to
be_i386
expect
(
pn
).
not_to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
not_to
be_text_executable
expect
(
pn
.
arch
).
to
eq
(
:universal
)
end
specify
"i386 dylib"
do
pn
=
dylib_path
(
"i386"
)
expect
(
pn
).
not_to
be_universal
expect
(
pn
).
to
be_i386
expect
(
pn
).
not_to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
not_to
be_text_executable
expect
(
pn
).
not_to
be_mach_o_bundle
end
specify
"x86_64 dylib"
do
pn
=
dylib_path
(
"x86_64"
)
expect
(
pn
).
not_to
be_universal
expect
(
pn
).
not_to
be_i386
expect
(
pn
).
to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
not_to
be_text_executable
expect
(
pn
).
not_to
be_mach_o_bundle
end
specify
"Mach-O executable"
do
pn
=
Pathname
.
new
(
"
#{
TEST_FIXTURE_DIR
}
/mach/a.out"
)
expect
(
pn
).
to
be_universal
expect
(
pn
).
not_to
be_i386
expect
(
pn
).
not_to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
not_to
be_dylib
expect
(
pn
).
to
be_mach_o_executable
expect
(
pn
).
not_to
be_text_executable
expect
(
pn
).
not_to
be_mach_o_bundle
end
specify
"fat bundle"
do
pn
=
bundle_path
(
"fat"
)
expect
(
pn
).
to
be_universal
expect
(
pn
).
not_to
be_i386
expect
(
pn
).
not_to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
not_to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
not_to
be_text_executable
expect
(
pn
).
to
be_mach_o_bundle
end
specify
"i386 bundle"
do
pn
=
bundle_path
(
"i386"
)
expect
(
pn
).
not_to
be_universal
expect
(
pn
).
to
be_i386
expect
(
pn
).
not_to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
not_to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
not_to
be_text_executable
expect
(
pn
).
to
be_mach_o_bundle
end
specify
"x86_64 bundle"
do
pn
=
bundle_path
(
"x86_64"
)
expect
(
pn
).
not_to
be_universal
expect
(
pn
).
not_to
be_i386
expect
(
pn
).
to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
not_to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
not_to
be_text_executable
expect
(
pn
).
to
be_mach_o_bundle
end
specify
"non-Mach-O"
do
pn
=
Pathname
.
new
(
"
#{
TEST_FIXTURE_DIR
}
/tarballs/testball-0.1.tbz"
)
expect
(
pn
).
not_to
be_universal
expect
(
pn
).
not_to
be_i386
expect
(
pn
).
not_to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
not_to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
not_to
be_text_executable
expect
(
pn
).
not_to
be_mach_o_bundle
expect
(
pn
.
arch
).
to
eq
(
:dunno
)
end
end
describe
ArchitectureListExtension
do
let
(
:archs
)
{
[
:i386
,
:x86_64
,
:ppc7400
,
:ppc64
].
extend
(
described_class
)
}
specify
"universal checks"
do
expect
(
archs
).
to
be_universal
expect
(
archs
).
to
be_intel_universal
expect
(
archs
).
to
be_ppc_universal
expect
(
archs
).
to
be_cross_universal
expect
(
archs
).
to
be_fat
non_universal
=
[
:i386
].
extend
(
described_class
)
expect
(
non_universal
).
not_to
be_universal
intel_only
=
[
:i386
,
:x86_64
].
extend
(
described_class
)
expect
(
intel_only
).
to
be_universal
expect
(
intel_only
).
not_to
be_ppc_universal
expect
(
intel_only
).
not_to
be_cross_universal
ppc_only
=
[
:ppc970
,
:ppc64
].
extend
(
described_class
)
expect
(
ppc_only
).
to
be_universal
expect
(
ppc_only
).
not_to
be_intel_universal
expect
(
ppc_only
).
not_to
be_cross_universal
cross
=
[
:ppc7400
,
:i386
].
extend
(
described_class
)
expect
(
cross
).
to
be_universal
expect
(
cross
).
not_to
be_intel_universal
expect
(
cross
).
not_to
be_ppc_universal
end
specify
"messaging flags"
do
archs
.
remove_ppc!
expect
(
archs
.
length
).
to
eq
(
2
)
expect
(
archs
.
as_arch_flags
).
to
match
(
/-arch i386/
)
expect
(
archs
.
as_arch_flags
).
to
match
(
/-arch x86_64/
)
end
specify
"architecture flags"
do
pn
=
dylib_path
(
"fat"
)
expect
(
pn
.
archs
).
to
be_intel_universal
expect
(
pn
.
archs
.
as_arch_flags
).
to
eq
(
"-arch x86_64 -arch i386"
)
expect
(
pn
.
archs
.
as_cmake_arch_flags
).
to
eq
(
"x86_64;i386"
)
end
end
describe
"text executables"
do
let
(
:pn
)
{
HOMEBREW_PREFIX
/
"an_executable"
}
after
(
:each
)
{
pn
.
unlink
}
specify
"simple shebang"
do
pn
.
write
"#!/bin/sh"
expect
(
pn
).
not_to
be_universal
expect
(
pn
).
not_to
be_i386
expect
(
pn
).
not_to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
not_to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
to
be_text_executable
expect
(
pn
.
archs
).
to
eq
([])
expect
(
pn
.
arch
).
to
eq
(
:dunno
)
end
specify
"shebang with options"
do
pn
.
write
"#! /usr/bin/perl -w"
expect
(
pn
).
not_to
be_universal
expect
(
pn
).
not_to
be_i386
expect
(
pn
).
not_to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
not_to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
to
be_text_executable
expect
(
pn
.
archs
).
to
eq
([])
expect
(
pn
.
arch
).
to
eq
(
:dunno
)
end
specify
"malformed shebang"
do
pn
.
write
" #!"
expect
(
pn
).
not_to
be_universal
expect
(
pn
).
not_to
be_i386
expect
(
pn
).
not_to
be_x86_64
expect
(
pn
).
not_to
be_ppc7400
expect
(
pn
).
not_to
be_ppc64
expect
(
pn
).
not_to
be_dylib
expect
(
pn
).
not_to
be_mach_o_executable
expect
(
pn
).
not_to
be_text_executable
expect
(
pn
.
archs
).
to
eq
([])
expect
(
pn
.
arch
).
to
eq
(
:dunno
)
end
end
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/os/mac/mach_test.rb
deleted
100644 → 0
+
0
−
211
View file @
e98b623b
require
"testing_env"
class
MachOPathnameTests
<
Homebrew
::
TestCase
def
test_fat_dylib
pn
=
dylib_path
(
"fat"
)
assert_predicate
pn
,
:universal?
refute_predicate
pn
,
:i386?
refute_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
assert_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
refute_predicate
pn
,
:text_executable?
assert_equal
:universal
,
pn
.
arch
end
def
test_i386_dylib
pn
=
dylib_path
(
"i386"
)
refute_predicate
pn
,
:universal?
assert_predicate
pn
,
:i386?
refute_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
assert_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
refute_predicate
pn
,
:text_executable?
refute_predicate
pn
,
:mach_o_bundle?
end
def
test_x86_64_dylib
pn
=
dylib_path
(
"x86_64"
)
refute_predicate
pn
,
:universal?
refute_predicate
pn
,
:i386?
assert_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
assert_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
refute_predicate
pn
,
:text_executable?
refute_predicate
pn
,
:mach_o_bundle?
end
def
test_mach_o_executable
pn
=
Pathname
.
new
(
"
#{
TEST_FIXTURE_DIR
}
/mach/a.out"
)
assert_predicate
pn
,
:universal?
refute_predicate
pn
,
:i386?
refute_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
refute_predicate
pn
,
:dylib?
assert_predicate
pn
,
:mach_o_executable?
refute_predicate
pn
,
:text_executable?
refute_predicate
pn
,
:mach_o_bundle?
end
def
test_fat_bundle
pn
=
bundle_path
(
"fat"
)
assert_predicate
pn
,
:universal?
refute_predicate
pn
,
:i386?
refute_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
refute_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
refute_predicate
pn
,
:text_executable?
assert_predicate
pn
,
:mach_o_bundle?
end
def
test_i386_bundle
pn
=
bundle_path
(
"i386"
)
refute_predicate
pn
,
:universal?
assert_predicate
pn
,
:i386?
refute_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
refute_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
refute_predicate
pn
,
:text_executable?
assert_predicate
pn
,
:mach_o_bundle?
end
def
test_x86_64_bundle
pn
=
bundle_path
(
"x86_64"
)
refute_predicate
pn
,
:universal?
refute_predicate
pn
,
:i386?
assert_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
refute_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
refute_predicate
pn
,
:text_executable?
assert_predicate
pn
,
:mach_o_bundle?
end
def
test_non_mach_o
pn
=
Pathname
.
new
(
"
#{
TEST_FIXTURE_DIR
}
/tarballs/testball-0.1.tbz"
)
refute_predicate
pn
,
:universal?
refute_predicate
pn
,
:i386?
refute_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
refute_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
refute_predicate
pn
,
:text_executable?
refute_predicate
pn
,
:mach_o_bundle?
assert_equal
:dunno
,
pn
.
arch
end
end
class
ArchitectureListExtensionTests
<
MachOPathnameTests
def
setup
super
@archs
=
[
:i386
,
:x86_64
,
:ppc7400
,
:ppc64
].
extend
(
ArchitectureListExtension
)
end
def
test_architecture_list_extension_universal_checks
assert_predicate
@archs
,
:universal?
assert_predicate
@archs
,
:intel_universal?
assert_predicate
@archs
,
:ppc_universal?
assert_predicate
@archs
,
:cross_universal?
assert_predicate
@archs
,
:fat?
non_universal
=
[
:i386
].
extend
ArchitectureListExtension
refute_predicate
non_universal
,
:universal?
intel_only
=
[
:i386
,
:x86_64
].
extend
ArchitectureListExtension
assert_predicate
intel_only
,
:universal?
refute_predicate
intel_only
,
:ppc_universal?
refute_predicate
intel_only
,
:cross_universal?
ppc_only
=
[
:ppc970
,
:ppc64
].
extend
ArchitectureListExtension
assert_predicate
ppc_only
,
:universal?
refute_predicate
ppc_only
,
:intel_universal?
refute_predicate
ppc_only
,
:cross_universal?
cross
=
[
:ppc7400
,
:i386
].
extend
ArchitectureListExtension
assert_predicate
cross
,
:universal?
refute_predicate
cross
,
:intel_universal?
refute_predicate
cross
,
:ppc_universal?
end
def
test_architecture_list_extension_massaging_flags
@archs
.
remove_ppc!
assert_equal
2
,
@archs
.
length
assert_match
(
/-arch i386/
,
@archs
.
as_arch_flags
)
assert_match
(
/-arch x86_64/
,
@archs
.
as_arch_flags
)
end
def
test_architecture_list_arch_flags_methods
pn
=
dylib_path
(
"fat"
)
assert_predicate
pn
.
archs
,
:intel_universal?
assert_equal
"-arch x86_64 -arch i386"
,
pn
.
archs
.
as_arch_flags
assert_equal
"x86_64;i386"
,
pn
.
archs
.
as_cmake_arch_flags
end
end
class
TextExecutableTests
<
Homebrew
::
TestCase
attr_reader
:pn
def
setup
super
@pn
=
HOMEBREW_PREFIX
.
join
(
"an_executable"
)
end
def
teardown
HOMEBREW_PREFIX
.
join
(
"an_executable"
).
unlink
super
end
def
test_simple_shebang
pn
.
write
"#!/bin/sh"
refute_predicate
pn
,
:universal?
refute_predicate
pn
,
:i386?
refute_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
refute_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
assert_predicate
pn
,
:text_executable?
assert_equal
[],
pn
.
archs
assert_equal
:dunno
,
pn
.
arch
end
def
test_shebang_with_options
pn
.
write
"#! /usr/bin/perl -w"
refute_predicate
pn
,
:universal?
refute_predicate
pn
,
:i386?
refute_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
refute_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
assert_predicate
pn
,
:text_executable?
assert_equal
[],
pn
.
archs
assert_equal
:dunno
,
pn
.
arch
end
def
test_malformed_shebang
pn
.
write
" #!"
refute_predicate
pn
,
:universal?
refute_predicate
pn
,
:i386?
refute_predicate
pn
,
:x86_64?
refute_predicate
pn
,
:ppc7400?
refute_predicate
pn
,
:ppc64?
refute_predicate
pn
,
:dylib?
refute_predicate
pn
,
:mach_o_executable?
refute_predicate
pn
,
:text_executable?
assert_equal
[],
pn
.
archs
assert_equal
:dunno
,
pn
.
arch
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment