8000 async-profiler 4.0 (tweak tests) · Homebrew/homebrew-core@82539c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 82539c5

Browse files
committed
async-profiler 4.0 (tweak tests)
1 parent 090cfa6 commit 82539c5

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

Formula/a/async-profiler.rb

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,44 @@ def install
2121
end
2222

2323
test do
24-
assert_match "Async-profiler #{version}", shell_output("#{bin}/asprof --version")
24+
output = shell_output("#{bin}/asprof --version")
25+
26+
if build.head?
27+
assert_match /^Async-profiler #{version}-#{Utils.git_head}.+/, output
28+
else
29+
assert_match "Async-profiler #{version}", output
30+
end
2531

2632
(testpath/"Main.java").write <<~JAVA
2733
public class Main {
2834
public static void main(String[] args) throws Exception {
29-
Thread.sleep(8_000);
35+
Thread.sleep(Integer.parseInt(args[0]));
3036
}
3137
}
3238
JAVA
3339

34-
pid = spawn Formula["openjdk"].bin/"java", testpath/"Main.java"
35-
system bin/"asprof",
36-
"-d", "2",
37-
"-f", testpath/"test-profile-via-attach.html",
38-
"jps"
39-
assert_path_exists testpath/"test-profile-via-attach.html"
40+
pid = spawn Formula["openjdk"].bin/"java", testpath/"Main.java", "8"
41+
begin
42+
sleep 1
43+
system bin/"asprof",
44+
"-d", "2",
45+
"-f", testpath/"test-profile-via-attach.html",
46+
"jps"
47+
assert_path_exists testpath/"test-profile-via-attach.html"
48+
ensure
49+
Process.kill("TERM", pid)
50+
Process.wait(pid)
51+
end
4052

4153
system Formula["openjdk"].bin/"java",
4254
"-agentpath:#{lib}/libasyncProfiler.dylib=start,event=cpu,lock=10ms,file=test-profile-via-lib.jfr",
43-
testpath/"Main.java"
55+
testpath/"Main.java", "2"
4456
assert_path_exists testpath/"test-profile-via-lib.jfr"
4557

4658
system bin/"jfrconv",
4759
"-o", "pprof",
4860
testpath/"test-profile-via-lib.jfr",
4961
testpath/"test-profile-via-lib.pprof"
5062
assert_path_exists testpath/"test-profile-via-lib.pprof"
51-
ensure
52-
Process.kill("TERM", pid)
5363
end
5464
end

0 commit comments

Comments
 (0)
0