@@ -21,34 +21,44 @@ def install
21
21
end
22
22
23
23
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
25
31
26
32
( testpath /"Main.java" ) . write <<~JAVA
27
33
public class Main {
28
34
public static void main(String[] args) throws Exception {
29
- Thread.sleep(8_000 );
35
+ Thread.sleep(Integer.parseInt(args[0]) );
30
36
}
31
37
}
32
38
JAVA
33
39
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
40
52
8518
div>
41
53
system Formula [ "openjdk" ] . bin /"java" ,
42
54
"-agentpath:#{ lib } /libasyncProfiler.dylib=start,event=cpu,lock=10ms,file=test-profile-via-lib.jfr" ,
43
- testpath /"Main.java"
55
+ testpath /"Main.java" , "2"
44
56
assert_path_exists testpath /"test-profile-via-lib.jfr"
45
57
46
58
system bin /"jfrconv" ,
47
59
"-o" , "pprof" ,
48
60
testpath /"test-profile-via-lib.jfr" ,
49
61
testpath /"test-profile-via-lib.pprof"
50
62
assert_path_exists testpath /"test-profile-via-lib.pprof"
51
- ensure
52
- Process . kill ( "TERM" , pid )
53
63
end
54
64
end
0 commit comments