tebako 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CMakeLists.txt +21 -29
- data/README.adoc +53 -28
- data/Rakefile +1 -1
- data/common.env +1 -1
- data/lib/tebako/cli.rb +23 -0
- data/lib/tebako/cli_helpers.rb +3 -3
- data/lib/tebako/packager/pass1.rb +3 -1
- data/lib/tebako/packager/pass2.rb +64 -274
- data/{tests-2/fixtures/gems-expressir/gems-expressir.rb → lib/tebako/packager/patch_helpers.rb} +30 -5
- data/lib/tebako/packager/patch_literals.rb +255 -0
- data/lib/tebako/version.rb +1 -1
- data/tebako.gemspec +1 -1
- data/version.txt +1 -1
- metadata +4 -62
- data/tests/scripts/cross-tests.sh +0 -34
- data/tests/scripts/functional-tests.sh +0 -335
- data/tests/test-00/test.rb +0 -4
- data/tests/test-01/tebako-test-run.rb +0 -5
- data/tests/test-09/tebako-test-0.0.1.gem +0 -0
- data/tests/test-11/bin/tebako-test-run.rb +0 -10
- data/tests/test-11/lib/tebako-test.rb +0 -20
- data/tests/test-11/tebako-test.gemspec +0 -15
- data/tests/test-12/tebako-test-a.gemspec +0 -15
- data/tests/test-12/tebako-test-b.gemspec +0 -15
- data/tests/test-13/bin/tebako-test-run.rb +0 -10
- data/tests/test-13/lib/tebako-test.rb +0 -20
- data/tests/test-13/tebako-test.gemspec +0 -15
- data/tests/test-15/Gemfile +0 -8
- data/tests/test-15/Rakefile +0 -4
- data/tests/test-15/bin/tebako-test-run.rb +0 -10
- data/tests/test-15/lib/tebako/bundle/test/version.rb +0 -9
- data/tests/test-15/lib/tebako/bundle/test.rb +0 -29
- data/tests/test-15/tebako-bundle-test.gemspec +0 -30
- data/tests/test-16/Gemfile +0 -8
- data/tests/test-16/Rakefile +0 -4
- data/tests/test-16/bin/tebako-test-run.rb +0 -10
- data/tests/test-16/lib/tebako/bundle/test/version.rb +0 -9
- data/tests/test-16/lib/tebako/bundle/test.rb +0 -29
- data/tests/test-16/tebako-bundle-test.gemspec +0 -24
- data/tests/test-18/Gemfile +0 -5
- data/tests/test-18/tebako-test-run.rb +0 -12
- data/tests/test-19/Gemfile +0 -6
- data/tests/test-19/tebako-test-run.rb +0 -11
- data/tests-2/fixtures/gems-bundler/Gemfile +0 -4
- data/tests-2/fixtures/gems-bundler/gems-bundler.rb +0 -34
- data/tests-2/fixtures/gems-byebug/Gemfile +0 -5
- data/tests-2/fixtures/gems-byebug/gems-byebug.rb +0 -31
- data/tests-2/fixtures/gems-expressir/Gemfile +0 -7
- data/tests-2/fixtures/gems-libmspack/Gemfile +0 -5
- data/tests-2/fixtures/gems-libmspack/gems-libmspack.rb +0 -91
- data/tests-2/fixtures/gems-sassc/Gemfile +0 -6
- data/tests-2/fixtures/gems-sassc/base_style/all.scss +0 -1
- data/tests-2/fixtures/gems-sassc/base_style/reset.scss +0 -100
- data/tests-2/fixtures/gems-sassc/gems-sassc.rb +0 -129
- data/tests-2/fixtures/gems-seven-zip/Gemfile +0 -7
- data/tests-2/fixtures/gems-seven-zip/gems-seven-zip.rb +0 -53
- data/tests-2/fixtures/launcher-coreincl/launcher-coreincl.rb +0 -29
- data/tests-2/fixtures/launcher-package/launcher-package.rb +0 -29
- data/tests-2/fixtures/launcher-pwd/launcher-pwd.rb +0 -28
- data/tests-2/fixtures/launcher-stdinredir/input.txt +0 -1
- data/tests-2/fixtures/launcher-stdinredir/launcher-stdinredir.rb +0 -31
- data/tests-2/fixtures/launcher-stdoutredir/launcher-stdoutredir.rb +0 -28
- data/tests-2/fixtures/patches-dir/level-1/level-2/file-1.txt +0 -1
- data/tests-2/fixtures/patches-dir/level-1/level-2/file-2.txt +0 -1
- data/tests-2/fixtures/patches-dir/level-1/level-2/file-3.txt +0 -1
- data/tests-2/fixtures/patches-dir/patches-dir.rb +0 -154
- data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-1.txt +0 -1
- data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-2.txt +0 -2
- data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-3.txt +0 -1
- data/tests-2/fixtures/patches-io-and-file/level-1/link-3 +0 -1
- data/tests-2/fixtures/patches-io-and-file/patches-io-and-file.rb +0 -87
- data/tests-2/fixtures/patches-main/patches-main.rb +0 -6
- data/tests-2/tebako-test.rb +0 -313
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2022-2023, [Ribose Inc](https://www.ribose.com).
|
|
4
|
-
# All rights reserved.
|
|
5
|
-
# This file is a part of tebako
|
|
6
|
-
#
|
|
7
|
-
# Redistribution and use in source and binary forms, with or without
|
|
8
|
-
# modification, are permitted provided that the following conditions
|
|
9
|
-
# are met:
|
|
10
|
-
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
-
# notice, this list of conditions and the following disclaimer.
|
|
12
|
-
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
-
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
-
# documentation and/or other materials provided with the distribution.
|
|
15
|
-
#
|
|
16
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
-
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
-
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
-
|
|
28
|
-
a = gets
|
|
29
|
-
exit 104 if a == "Hello, World!\r\n"
|
|
30
|
-
exit 104 if a == "Hello, World!\n"
|
|
31
|
-
exit 103
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2022, [Ribose Inc](https://www.ribose.com).
|
|
4
|
-
# All rights reserved.
|
|
5
|
-
# This file is a part of tebako
|
|
6
|
-
#
|
|
7
|
-
# Redistribution and use in source and binary forms, with or without
|
|
8
|
-
# modification, are permitted provided that the following conditions
|
|
9
|
-
# are met:
|
|
10
|
-
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
-
# notice, this list of conditions and the following disclaimer.
|
|
12
|
-
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
-
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
-
# documentation and/or other materials provided with the distribution.
|
|
15
|
-
#
|
|
16
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
-
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
-
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
-
|
|
28
|
-
puts "Hello, World!"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This is file-1 txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This is file-2.txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This is file-3.txt
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2021-2023 [Ribose Inc](https://www.ribose.com).
|
|
4
|
-
# All rights reserved.
|
|
5
|
-
# This file is a part of tebako
|
|
6
|
-
#
|
|
7
|
-
# Redistribution and use in source and binary forms, with or without
|
|
8
|
-
# modification, are permitted provided that the following conditions
|
|
9
|
-
# are met:
|
|
10
|
-
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
-
# notice, this list of conditions and the following disclaimer.
|
|
12
|
-
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
-
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
-
# documentation and/or other materials provided with the distribution.
|
|
15
|
-
#
|
|
16
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
-
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
-
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
-
|
|
28
|
-
puts "===== Dir test ====="
|
|
29
|
-
|
|
30
|
-
# test 1 chdir absolute - getwd
|
|
31
|
-
EXPECTED_CWD_1 = "/__tebako_memfs__/local/"
|
|
32
|
-
print "chdir '#{File.dirname(__FILE__)}' ... "
|
|
33
|
-
Dir.chdir(File.dirname(__FILE__))
|
|
34
|
-
cwd = Dir.getwd
|
|
35
|
-
raise "getwd returned #{cwd} while #{EXPECTED_CWD_1} was expected" unless cwd.eql? EXPECTED_CWD_1
|
|
36
|
-
|
|
37
|
-
print "OK(success)\n"
|
|
38
|
-
|
|
39
|
-
# test 2 chdir relative - getwd
|
|
40
|
-
EXPECTED_CWD_2 = "/__tebako_memfs__/local/level-1/"
|
|
41
|
-
print "chdir 'level-1' ... "
|
|
42
|
-
Dir.chdir("level-1")
|
|
43
|
-
cwd = Dir.getwd
|
|
44
|
-
raise "getwd returned #{cwd} while #{EXPECTED_CWD_2} was expected" unless cwd.eql? EXPECTED_CWD_2
|
|
45
|
-
|
|
46
|
-
print "OK(success)\n"
|
|
47
|
-
|
|
48
|
-
# test 3 chdir relative (does not exit) - getwd
|
|
49
|
-
print "chdir 'does-not-exists' ... "
|
|
50
|
-
begin
|
|
51
|
-
Dir.chdir("does-not-exist")
|
|
52
|
-
failed = false
|
|
53
|
-
rescue Errno::ENOENT
|
|
54
|
-
failed = true
|
|
55
|
-
end
|
|
56
|
-
raise "chdir succeeded while exception was expected" unless failed
|
|
57
|
-
|
|
58
|
-
cwd = Dir.getwd
|
|
59
|
-
raise "Getwd returned #{cwd} while #{EXPECTED_CWD_2} was expected" unless cwd.eql? EXPECTED_CWD_2
|
|
60
|
-
|
|
61
|
-
print "OK(failure)\n"
|
|
62
|
-
|
|
63
|
-
# test 4 chdir absolute (does not exit) - getwd
|
|
64
|
-
print "chdir '/bin/does-not-exists' ... "
|
|
65
|
-
begin
|
|
66
|
-
Dir.chdir("/bin/does-not-exist")
|
|
67
|
-
failed = false
|
|
68
|
-
rescue Errno::ENOENT
|
|
69
|
-
failed = true
|
|
70
|
-
end
|
|
71
|
-
raise "chdir succeeded while exception was expected" unless failed
|
|
72
|
-
|
|
73
|
-
cwd = Dir.getwd
|
|
74
|
-
raise "getwd returned #{cwd} while #{EXPECTED_CWD_2} was expected" unless cwd.eql? EXPECTED_CWD_2
|
|
75
|
-
|
|
76
|
-
print "OK(failure)\n"
|
|
77
|
-
|
|
78
|
-
# test 5 open - read - tell - seek - close - rewind
|
|
79
|
-
print "open - read - tell - seek - close @ '/__tebako_memfs__/local/level-1/level-2' ... "
|
|
80
|
-
a_dir = Dir.new("/__tebako_memfs__/local/level-1/level-2")
|
|
81
|
-
|
|
82
|
-
r = a_dir.read
|
|
83
|
-
p = a_dir.tell
|
|
84
|
-
raise "Dir.read returned #{r} while '.' was expected" unless r.eql? "."
|
|
85
|
-
raise "Dir.tell returned #{p} while 1 was expected" unless p.eql? 1
|
|
86
|
-
|
|
87
|
-
r = a_dir.read
|
|
88
|
-
p = a_dir.tell
|
|
89
|
-
raise "Dir.read returned #{r} while '..' was expected" unless r.eql? ".."
|
|
90
|
-
raise "Dir.tell returned #{p} while 2 was expected" unless p.eql? 2
|
|
91
|
-
|
|
92
|
-
re = Regexp.new("file-..txt").freeze
|
|
93
|
-
(3..5).each do |i|
|
|
94
|
-
r = a_dir.read
|
|
95
|
-
p = a_dir.tell
|
|
96
|
-
raise "Dir.read returned #{r} while 'file-?.txt' was expected" unless r =~ re
|
|
97
|
-
raise "Dir.tell returned #{p} while #{i} was expected" unless p.eql? i
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
a_dir.seek(1)
|
|
101
|
-
r = a_dir.read
|
|
102
|
-
p = a_dir.tell
|
|
103
|
-
raise "Dir.read returned #{r} while '..' was expected" unless r.eql? ".."
|
|
104
|
-
raise "Dir.tell returned #{p} while 2 was expected" unless p.eql? 2
|
|
105
|
-
|
|
106
|
-
a_dir.rewind
|
|
107
|
-
p = a_dir.tell
|
|
108
|
-
raise "Dir.tell returned #{p} while 1 was expected" unless p.eql? 0
|
|
109
|
-
|
|
110
|
-
r = a_dir.read
|
|
111
|
-
p = a_dir.tell
|
|
112
|
-
raise "Dir.read returned #{r} while '.' was expected" unless r.eql? "."
|
|
113
|
-
raise "Dir.tell returned #{p} while 1 was expected" unless p.eql? 1
|
|
114
|
-
|
|
115
|
-
p = a_dir.close
|
|
116
|
-
raise "Dir.close returned #{p} while nil was expected" unless p.nil?
|
|
117
|
-
|
|
118
|
-
print "OK(match)\n"
|
|
119
|
-
|
|
120
|
-
# test 7 glob
|
|
121
|
-
print "[\"**/*.txt\", base:\"/__tebako_memfs__/local/\"] ... "
|
|
122
|
-
fls = Dir["**/*.txt", base: "/__tebako_memfs__/local/"]
|
|
123
|
-
EXPECTED_1 = ["level-1/level-2/file-1.txt", "level-1/level-2/file-2.txt", "level-1/level-2/file-3.txt"].freeze
|
|
124
|
-
|
|
125
|
-
if fls.difference(EXPECTED_1).any? || EXPECTED_1.difference(fls).any?
|
|
126
|
-
raise "Dir[] returned #{fls} while #{EXPECTED_1} was expected"
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
print "OK(match)\n"
|
|
130
|
-
|
|
131
|
-
# test 8 glob
|
|
132
|
-
print "[\"/__tebako_memfs__/local/**/file-1.txt\"] ... "
|
|
133
|
-
fls = Dir["/__tebako_memfs__/local/**/file-1.txt"]
|
|
134
|
-
EXPECTED_2 = ["/__tebako_memfs__/local/level-1/level-2/file-1.txt"].freeze
|
|
135
|
-
|
|
136
|
-
if fls.difference(EXPECTED_2).any? || EXPECTED_2.difference(fls).any?
|
|
137
|
-
raise "Dir[] returned #{fls} while #{EXPECTED_2} was expected"
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
print "OK(match)\n"
|
|
141
|
-
|
|
142
|
-
# test 9 Dir.empty?
|
|
143
|
-
print "Dir.empty?(\"/__tebako_memfs__/local/level-1/level-2\") ..."
|
|
144
|
-
r = Dir.empty?("/__tebako_memfs__/local/level-1/level-2")
|
|
145
|
-
raise "Dir.empty? returned #{r} while 'false' was expected" if r
|
|
146
|
-
|
|
147
|
-
print "OK(match)\n"
|
|
148
|
-
|
|
149
|
-
# test 10 Dir.empty?
|
|
150
|
-
print "Dir.empty?(\"/__tebako_memfs__/local/level-1/level-2/level-3\") ..."
|
|
151
|
-
r = Dir.empty?("/__tebako_memfs__/local/level-1/level-2/level-3")
|
|
152
|
-
raise "Dir.empty? returned #{r} while 'true' was expected" unless r
|
|
153
|
-
|
|
154
|
-
print "OK(match)\n"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This is file-1.txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This is file-3.txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
level-2/file-3.txt
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2021, [Ribose Inc](https://www.ribose.com).
|
|
4
|
-
# All rights reserved.
|
|
5
|
-
# This file is a part of tebako
|
|
6
|
-
#
|
|
7
|
-
# Redistribution and use in source and binary forms, with or without
|
|
8
|
-
# modification, are permitted provided that the following conditions
|
|
9
|
-
# are met:
|
|
10
|
-
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
-
# notice, this list of conditions and the following disclaimer.
|
|
12
|
-
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
-
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
-
# documentation and/or other materials provided with the distribution.
|
|
15
|
-
#
|
|
16
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
-
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
-
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
-
|
|
28
|
-
puts "===== File tests ====="
|
|
29
|
-
|
|
30
|
-
# test 1 exist? (aka stat)
|
|
31
|
-
print "exist?(\"/__tebako_memfs__/local/level-1/level-2/file-1.txt\") ... "
|
|
32
|
-
r = File.exist?("/__tebako_memfs__/local/level-1/level-2/file-1.txt")
|
|
33
|
-
raise "exist? returned '#{r}' while 'true' was expected" unless r
|
|
34
|
-
|
|
35
|
-
print "OK(success)\n"
|
|
36
|
-
|
|
37
|
-
# test 2 executable_real? (aka access)
|
|
38
|
-
# print "executable_real?(\"/__tebako_memfs__/local/level-1/level-2/file-2.txt\") ... "
|
|
39
|
-
# r = File.executable_real?("/__tebako_memfs__/local/level-1/level-2/file-2.txt")
|
|
40
|
-
# raise "executable_real? returned '#{r}' while 'false' was expected" if r
|
|
41
|
-
# print "OK(failure)\n"
|
|
42
|
-
|
|
43
|
-
# test 3 open - read - seak - rewind - close
|
|
44
|
-
print "open - seek - read - rewind - close ... "
|
|
45
|
-
Dir.chdir("/__tebako_memfs__/local/level-1/level-2")
|
|
46
|
-
File.open("file-2.txt", "r") do |f|
|
|
47
|
-
r = f.read(18)
|
|
48
|
-
raise "read returned '#{r}' while 'This is file-2.txt' was expected" unless r.eql? "This is file-2.txt"
|
|
49
|
-
|
|
50
|
-
s = f.pos
|
|
51
|
-
raise "pos returned '#{s}' while '18' was expected" unless s.eql? 18
|
|
52
|
-
|
|
53
|
-
f.seek(5, :SET)
|
|
54
|
-
s = f.pos
|
|
55
|
-
raise "pos returned '#{s}' while '5' was expected" unless s.eql? 5
|
|
56
|
-
|
|
57
|
-
r = f.read(13)
|
|
58
|
-
raise "read returned '#{r}' while 'is file-2.txt' was expected" unless r.eql? "is file-2.txt"
|
|
59
|
-
|
|
60
|
-
f.rewind
|
|
61
|
-
s = f.pos
|
|
62
|
-
raise "pos returned '#{s}' while '5' was expected" unless s.eql? 0
|
|
63
|
-
|
|
64
|
-
r = f.read(4)
|
|
65
|
-
raise "read returned '#{r}' while 'This' was expected" unless r.eql? "This"
|
|
66
|
-
end
|
|
67
|
-
print "OK(match)\n"
|
|
68
|
-
|
|
69
|
-
# test 4 open - pread - close
|
|
70
|
-
print "open - pread - close ... "
|
|
71
|
-
Dir.chdir("/__tebako_memfs__/local/level-1/level-2")
|
|
72
|
-
File.open("file-1.txt", "r") do |f|
|
|
73
|
-
r = f.pread(13, 5)
|
|
74
|
-
raise "read returned '#{r}' while 'is file-1.txt' was expected" unless r.eql? "is file-1.txt"
|
|
75
|
-
end
|
|
76
|
-
print "OK(match)\n"
|
|
77
|
-
|
|
78
|
-
# test 5 lstat - readlink
|
|
79
|
-
print "readlink ... "
|
|
80
|
-
Dir.chdir("/__tebako_memfs__/local/level-1")
|
|
81
|
-
s = File.lstat("/__tebako_memfs__/local/level-1/link-3").size
|
|
82
|
-
raise "lstat returned '#{s}' while '18' was expected" unless s.eql? 18
|
|
83
|
-
|
|
84
|
-
r = File.readlink("link-3")
|
|
85
|
-
raise "readlink returned '#{r}' while 'level-2/file-3.txt' was expected" unless r.eql? "level-2/file-3.txt"
|
|
86
|
-
|
|
87
|
-
print "OK(match)\n"
|
data/tests-2/tebako-test.rb
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
# Copyright (c) 2021-2023 [Ribose Inc](https://www.ribose.com).
|
|
5
|
-
# All rights reserved.
|
|
6
|
-
# This file is a part of tebako
|
|
7
|
-
#
|
|
8
|
-
# Redistribution and use in source and binary forms, with or without
|
|
9
|
-
# modification, are permitted provided that the following conditions
|
|
10
|
-
# are met:
|
|
11
|
-
# 1. Redistributions of source code must retain the above copyright
|
|
12
|
-
# notice, this list of conditions and the following disclaimer.
|
|
13
|
-
# 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
-
# notice, this list of conditions and the following disclaimer in the
|
|
15
|
-
# documentation and/or other materials provided with the distribution.
|
|
16
|
-
#
|
|
17
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
-
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
19
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
20
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
21
|
-
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
|
|
29
|
-
require "English"
|
|
30
|
-
require "tmpdir"
|
|
31
|
-
require "fileutils"
|
|
32
|
-
require "rbconfig"
|
|
33
|
-
require "pathname"
|
|
34
|
-
require "rubygems"
|
|
35
|
-
require "open3"
|
|
36
|
-
require "minitest/autorun"
|
|
37
|
-
|
|
38
|
-
# Tebako test set
|
|
39
|
-
# rubocop:disable Metrics/ClassLength
|
|
40
|
-
class TebakoTest < MiniTest::Test
|
|
41
|
-
# Path to test fixtures.
|
|
42
|
-
FixturePath = File.expand_path(File.join(File.dirname(__FILE__), "fixtures"))
|
|
43
|
-
Prefix = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
|
44
|
-
Tebako = File.join(Prefix, "exe", "tebako")
|
|
45
|
-
|
|
46
|
-
def initialize(*args)
|
|
47
|
-
super(*args)
|
|
48
|
-
@testnum = 0
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Sets up temporary environment variables and yields to the
|
|
52
|
-
# block. When the block exits, the environment variables are set
|
|
53
|
-
# back to their original values.
|
|
54
|
-
def with_env(hash)
|
|
55
|
-
old = {}
|
|
56
|
-
hash.each do |k, v|
|
|
57
|
-
old[k] = ENV.fetch(k, nil)
|
|
58
|
-
ENV[k] = v
|
|
59
|
-
end
|
|
60
|
-
begin
|
|
61
|
-
yield
|
|
62
|
-
ensure
|
|
63
|
-
hash.each { |k, _v| ENV[k] = old[k] }
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# Sets up an directory with a copy of a fixture and yields to the
|
|
68
|
-
# block, then cleans up everything. A fixture here is a hierachy of
|
|
69
|
-
# files located in test/fixtures.
|
|
70
|
-
def with_fixture(name, target_path = nil, &block)
|
|
71
|
-
path = File.join(FixturePath, name)
|
|
72
|
-
with_tmpdir([], target_path) do |tmpdirname|
|
|
73
|
-
FileUtils.cp_r path, tmpdirname
|
|
74
|
-
FileUtils.cd tmpdirname, &block
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# Creates temporary dir, copies files to it, cleans everything when the business is finished
|
|
79
|
-
def with_tmpdir(files = [], path = nil)
|
|
80
|
-
tempdirname = path || File.join("/tmp", "tebako-test-#{$PROCESS_ID}-#{rand 2**32}").tr("\\", "/")
|
|
81
|
-
FileUtils.mkdir_p tempdirname
|
|
82
|
-
begin
|
|
83
|
-
FileUtils.cp files, tempdirname
|
|
84
|
-
yield(tempdirname)
|
|
85
|
-
ensure
|
|
86
|
-
FileUtils.rm_rf tempdirname
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Create a pristine environment to test built executables. Files are
|
|
91
|
-
# copied and the PATH environment is set to the minimal.
|
|
92
|
-
# yeilds the name for pristine temp dir (as opposed to temp dir used for packaging)
|
|
93
|
-
def pristine_env(*files)
|
|
94
|
-
with_tmpdir files do |tempdirname|
|
|
95
|
-
with_env "PATH" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" do
|
|
96
|
-
yield(tempdirname)
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def ruby_ver
|
|
102
|
-
ENV.fetch("RUBY_VER", "3.0.6")
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# Run 'tebako press ...'
|
|
106
|
-
def press(tebako, name, package, prefix)
|
|
107
|
-
cmd = "#{tebako} press -R #{ruby_ver} -o #{package} -e #{name}.rb -r #{name} -p '#{prefix}'"
|
|
108
|
-
out, st = Open3.capture2e(cmd)
|
|
109
|
-
if st.exitstatus != 0
|
|
110
|
-
puts "\"cmd\" failed with status #{st.exitstatus}"
|
|
111
|
-
puts out
|
|
112
|
-
end
|
|
113
|
-
assert_equal 0, st.exitstatus
|
|
114
|
-
assert File.exist?(package)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# A kind of standart creates names - tmp dir with fixture - press sequence
|
|
118
|
-
def with_fixture_press_and_env(name)
|
|
119
|
-
package = "#{name}-package"
|
|
120
|
-
with_fixture name do
|
|
121
|
-
press(Tebako, name, package, Prefix)
|
|
122
|
-
pristine_env package do |tempdirname|
|
|
123
|
-
yield "#{tempdirname}/#{package}"
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# Specified gems should be automatically included and usable in packaged app
|
|
129
|
-
def test_216_byebug
|
|
130
|
-
name = "gems-byebug"
|
|
131
|
-
with_fixture_press_and_env name do |package|
|
|
132
|
-
out, st = Open3.capture2(package)
|
|
133
|
-
assert_equal 0, st.exitstatus
|
|
134
|
-
assert_equal out, "Hello! Byebug welcomes you to the magic world of ruby gems.\n"
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
# Specified gems should be automatically included and usable in packaged app
|
|
139
|
-
def test_215_expressir
|
|
140
|
-
name = "gems-expressir"
|
|
141
|
-
with_fixture_press_and_env name do |package|
|
|
142
|
-
out, st = Open3.capture2(package)
|
|
143
|
-
assert_equal 0, st.exitstatus
|
|
144
|
-
assert_match(/Hello! Expressir gem welcomes you to the magic world of ruby gems./, out)
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
# Specified gems should be automatically included and usable in packaged app
|
|
149
|
-
def test_214_sassc
|
|
150
|
-
name = "gems-sassc"
|
|
151
|
-
with_fixture_press_and_env name do |package|
|
|
152
|
-
out, st = Open3.capture2(package)
|
|
153
|
-
assert_equal 0, st.exitstatus
|
|
154
|
-
assert_match(/Hello! SassC gem welcomes you to the magic world of ruby gems./, out)
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
# Specified gems should be automatically included and usable in packaged app
|
|
159
|
-
def test_213_libmspack
|
|
160
|
-
name = "gems-libmspack"
|
|
161
|
-
with_fixture_press_and_env name do |package|
|
|
162
|
-
out, st = Open3.capture2(package)
|
|
163
|
-
assert_equal 0, st.exitstatus
|
|
164
|
-
assert_match(/Hello! libmspack welcomes you to the magic world of ruby gems./, out)
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
# Specified gems should be automatically included and usable in packaged app
|
|
169
|
-
def test_212_seven_zip
|
|
170
|
-
name = "gems-seven-zip"
|
|
171
|
-
with_fixture_press_and_env name do |package|
|
|
172
|
-
out, st = Open3.capture2(package)
|
|
173
|
-
assert_equal 0, st.exitstatus
|
|
174
|
-
assert_match(/Hello! SevenZipRuby welcomes you to the magic world of ruby gems/, out)
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
# Specified gems should be automatically included and usable in packaged app
|
|
179
|
-
def test_211_bundler
|
|
180
|
-
name = "gems-bundler"
|
|
181
|
-
with_fixture_press_and_env name do |package|
|
|
182
|
-
out, st = Open3.capture2(package)
|
|
183
|
-
assert_equal 0, st.exitstatus
|
|
184
|
-
assert_equal out, "Hello! Bundler welcomes you to the magic world of ruby gems.\n"
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
# Test io.c and file.c patching
|
|
189
|
-
def test_122_io_and_file
|
|
190
|
-
name = "patches-io-and-file"
|
|
191
|
-
with_fixture_press_and_env name do |package|
|
|
192
|
-
_, st = Open3.capture2(package)
|
|
193
|
-
assert_equal 0, st.exitstatus
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
# Test dir.c patching
|
|
198
|
-
def test_122_dir
|
|
199
|
-
name = "patches-dir"
|
|
200
|
-
FileUtils.mkdir_p File.join(FixturePath, name, "level-1/level-2/level-3")
|
|
201
|
-
with_fixture_press_and_env name do |package|
|
|
202
|
-
_, st = Open3.capture2(package)
|
|
203
|
-
assert_equal 0, st.exitstatus
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
# Test main.c patching as relates to scrip argument handling
|
|
208
|
-
# Test that scripts can exit with a specific exit status code
|
|
209
|
-
def test_121_main
|
|
210
|
-
name = "patches-main"
|
|
211
|
-
with_fixture_press_and_env name do |package|
|
|
212
|
-
_, st = Open3.capture2("#{package} foo \"bar baz \\\"quote\\\"\"")
|
|
213
|
-
assert_equal 5, st.exitstatus
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# Test:
|
|
218
|
-
# -- that executable can write a file to the current working directory (io.c, file.c patching)
|
|
219
|
-
# -- short options without whitespaces
|
|
220
|
-
def test_105_launcher_pwd
|
|
221
|
-
name = "launcher-pwd"
|
|
222
|
-
with_fixture_press_and_env name do |package|
|
|
223
|
-
_, st = Open3.capture2(package.to_s)
|
|
224
|
-
assert_equal 0, st.exitstatus
|
|
225
|
-
assert File.exist?("output.txt")
|
|
226
|
-
assert_equal "output", File.read("output.txt")
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
# Test that executable can use ruby standard libraries (i.e. cgi)
|
|
231
|
-
def test_104_launcher_coreincl
|
|
232
|
-
name = "launcher-coreincl"
|
|
233
|
-
with_fixture_press_and_env name do |package|
|
|
234
|
-
_, st = Open3.capture2(package)
|
|
235
|
-
assert_equal 0, st.exitstatus
|
|
236
|
-
assert File.exist?("output.txt")
|
|
237
|
-
assert_equal "3 < 5", File.read("output.txt")
|
|
238
|
-
end
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
# Test that the standard output from a script can be redirected to a file.
|
|
242
|
-
def test_103_launcher_stdoutredir
|
|
243
|
-
name = "launcher-stdoutredir"
|
|
244
|
-
with_fixture_press_and_env name do |package|
|
|
245
|
-
system("#{package} > output.txt")
|
|
246
|
-
assert File.exist?("output.txt")
|
|
247
|
-
o = File.read("output.txt")
|
|
248
|
-
assert ["Hello, World!\n", "Hello, World!\r\n"].include?(o)
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
# Test that the standard input to a script can be redirected from a file.
|
|
253
|
-
def test_102_launcher_stdinredir
|
|
254
|
-
name = "launcher-stdinredir"
|
|
255
|
-
package = "#{name}-package"
|
|
256
|
-
with_fixture name do
|
|
257
|
-
press(Tebako, name, package, Prefix)
|
|
258
|
-
pristine_env package, "#{name}/input.txt" do |tempdirname|
|
|
259
|
-
_, st = Open3.capture2("#{tempdirname}/#{package} < #{tempdirname}/input.txt")
|
|
260
|
-
assert_equal 104, st.exitstatus
|
|
261
|
-
end
|
|
262
|
-
end
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
# Test :
|
|
266
|
-
# -- that we can build and run executables.
|
|
267
|
-
# -- short options with whitespaces
|
|
268
|
-
# -- that we are linking to known set of shared libraries (https://github.com/tamatebako/tebako/issues/42)
|
|
269
|
-
|
|
270
|
-
def expected_libs
|
|
271
|
-
case RbConfig::CONFIG["target_os"]
|
|
272
|
-
when /darwin/
|
|
273
|
-
["Security.framework", "Foundation.framework", "CoreFoundation.framework", "libSystem",
|
|
274
|
-
"libc++", "launcher-package-package:"]
|
|
275
|
-
# This is the test program itself: 'launcher-package-package:'
|
|
276
|
-
when /linux-musl/
|
|
277
|
-
["libc.musl-x86_64.so", "ld-musl-x86_64.so"]
|
|
278
|
-
else # linux-gnu assumed
|
|
279
|
-
["linux-vdso.so", "libpthread.so", "libdl.so", "libc.so", "ld-linux-", "libm.so",
|
|
280
|
-
"librt.so", "libgcc_s.so"]
|
|
281
|
-
end
|
|
282
|
-
end
|
|
283
|
-
|
|
284
|
-
def actual_libs(package)
|
|
285
|
-
out, st = if RbConfig::CONFIG["host_os"] =~ /darwin/
|
|
286
|
-
Open3.capture2("otool -L #{package}")
|
|
287
|
-
else # linux assumed
|
|
288
|
-
Open3.capture2("ldd #{package}")
|
|
289
|
-
end
|
|
290
|
-
assert_equal 0, st.exitstatus
|
|
291
|
-
out.lines.map(&:strip)
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
def check_libs(package)
|
|
295
|
-
l = actual_libs(package.to_s)
|
|
296
|
-
l.delete_if { |ln| expected_libs.any? { |lib| ln.include?(lib) } }
|
|
297
|
-
assert_equal 0, l.size, "Unexpected references to shared libraries #{l}"
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
def test_101_launcher
|
|
301
|
-
name = "launcher-package"
|
|
302
|
-
package = "#{name}-package"
|
|
303
|
-
with_fixture name do
|
|
304
|
-
press(Tebako, name, package, Prefix)
|
|
305
|
-
pristine_env package do |tempdirname|
|
|
306
|
-
_, st = Open3.capture2("#{tempdirname}/#{package}")
|
|
307
|
-
assert_equal 0, st.exitstatus
|
|
308
|
-
check_libs(package.to_s)
|
|
309
|
-
end
|
|
310
|
-
end
|
|
311
|
-
end
|
|
312
|
-
end
|
|
313
|
-
# rubocop:enable Metrics/ClassLength
|