1 | #!/usr/bin/ruby |
---|
2 | |
---|
3 | require 'fileutils' |
---|
4 | require 'rbconfig' |
---|
5 | include FileUtils |
---|
6 | |
---|
7 | rc_d = 'rc.d' |
---|
8 | if not File.exist? rc_d then |
---|
9 | rc_d = "../lib/smalltalkx/6.2.5/lib/rc.d" |
---|
10 | end |
---|
11 | |
---|
12 | token="bug_86_starting_stx_with_saved_image_kills_the_whole_environment" |
---|
13 | |
---|
14 | |
---|
15 | stx_cmd = nil |
---|
16 | if File.exist? 'stx.com' then |
---|
17 | stx_cmd = 'stx.com' |
---|
18 | elsif File.exist? 'stx-bin.com' then |
---|
19 | stx_cmd = 'stx-bin.com' |
---|
20 | else |
---|
21 | stx_cmd = './stx' |
---|
22 | end |
---|
23 | puts "stx_cmd = #{stx_cmd.inspect}" |
---|
24 | |
---|
25 | File.open("#{rc_d}/99-#{token}.rc", "w") do | f | |
---|
26 | f.write <<END |
---|
27 | (OperatingSystem getEnvironment: '#{token}') = '1' ifTrue:[ |
---|
28 | Smalltalk addStartBlock:[ |
---|
29 | | p | |
---|
30 | [ |
---|
31 | "FRESH start" |
---|
32 | Smalltalk addImageStartBlock:[ |
---|
33 | "RESTARTING from a snapshot" |
---|
34 | [ |
---|
35 | | ok | |
---|
36 | |
---|
37 | Stdout nextPutLine: 'Restarted from snapshot.'. |
---|
38 | ok := Dialog confirm: 'Does the grid shown in UIPainter''s canvas look OK?'. |
---|
39 | (OperatingSystem getEnvironment: '#{token}') = '1' ifTrue:[ |
---|
40 | Smalltalk exit: 121 + (ok ifTrue:[0] ifFalse:[10]). |
---|
41 | ]. |
---|
42 | ] fork. |
---|
43 | ]. |
---|
44 | p := UIPainter new. |
---|
45 | p open. |
---|
46 | p gridShownHolder value: true. |
---|
47 | p alignToGridHolder value: true. |
---|
48 | p := nil. |
---|
49 | Delay waitForSeconds: 1. |
---|
50 | Smalltalk garbageCollect. |
---|
51 | ObjectMemory snapShot. |
---|
52 | Smalltalk exit: 123. |
---|
53 | ] fork. |
---|
54 | ]. |
---|
55 | ] |
---|
56 | END |
---|
57 | end |
---|
58 | |
---|
59 | ENV[token] = '1' |
---|
60 | |
---|
61 | # Step 1. |
---|
62 | rm_f 'st.img'; rm_f 'st.sav'; rm_f 'st.chg' |
---|
63 | |
---|
64 | # Step 2. |
---|
65 | system "#{stx_cmd} -I --quick" |
---|
66 | if $?.exitstatus != 123 then |
---|
67 | raise Exception.new("stx failed to execute (status #{$?.exitstatus})"); |
---|
68 | end |
---|
69 | |
---|
70 | if not File.exist? 'st.img' then |
---|
71 | raise Exception.new("st.img was not saved") |
---|
72 | end |
---|
73 | |
---|
74 | # Step 3. |
---|
75 | system "#{stx_cmd} -i st.img" |
---|
76 | if $?.exitstatus != 121 then |
---|
77 | puts |
---|
78 | puts "Start gdb as:" |
---|
79 | puts |
---|
80 | puts ' C:\mingw64\bin\gdb.exe --args stx-bin.com -i st.img' |
---|
81 | puts |
---|
82 | raise Exception.new("stx failed to restart from a snapshot (status #{$?.exitstatus})"); |
---|
83 | end |
---|
84 | |
---|
85 | puts |
---|
86 | puts "PASSED" |
---|