-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathvalidate-rubygems.sh
More file actions
executable file
·182 lines (154 loc) · 3.93 KB
/
validate-rubygems.sh
File metadata and controls
executable file
·182 lines (154 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
# Script to validate QuickFix Ruby gem installed from RubyGems or test repository
# Usage: ./validate-rubygems.sh [--test]
# Default: validates from RubyGems.org
# With --test: validates from test.rubygems.org
TEST_SERVER=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--test)
TEST_SERVER=true
shift
;;
*)
shift
;;
esac
done
echo "=== Validating QuickFix Ruby Gem from RubyGems ==="
echo ""
# Check if gem command is available
if ! command -v gem &> /dev/null; then
echo "Error: gem command not found"
echo "Install Ruby to get the gem command"
exit 1
fi
# Determine target server
if [ "$TEST_SERVER" = true ]; then
SERVER_NAME="test.rubygems.org"
echo "Validating gem from test server: $SERVER_NAME"
else
SERVER_NAME="RubyGems.org"
echo "Validating gem from production: $SERVER_NAME"
fi
echo ""
# Get installed version
INSTALLED=$(gem list quickfix_ruby | grep quickfix_ruby)
if [ -z "$INSTALLED" ]; then
echo "quickfix_ruby gem not found locally"
echo ""
echo "Installing quickfix_ruby from $SERVER_NAME..."
echo ""
if [ "$TEST_SERVER" = true ]; then
gem install quickfix_ruby --source https://test.rubygems.org/api/v1/ -V 2>&1 | tail -20
else
gem install quickfix_ruby -V 2>&1 | tail -20
fi
if [ $? -ne 0 ]; then
echo ""
echo "Error: Failed to install quickfix_ruby"
exit 1
fi
fi
echo ""
echo "=== Running Validation Tests ==="
echo ""
# Test 1: Check gem is installed
echo "Test 1: Checking gem installation..."
if gem list quickfix_ruby | grep -q quickfix_ruby; then
GEM_VERSION=$(gem list quickfix_ruby | grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\..*)?')
echo "✓ Gem installed: quickfix_ruby $GEM_VERSION"
else
echo "✗ Gem not installed"
exit 1
fi
# Test 2: Check core classes available
echo ""
echo "Test 2: Checking core QuickFIX classes..."
# Create a test Ruby script to verify classes
TEST_SCRIPT=$(mktemp)
cat > "$TEST_SCRIPT" << 'EOF'
begin
require 'quickfix'
# Test basic classes
classes_to_test = [
'Quickfix::Session',
'Quickfix::SocketInitiator',
'Quickfix::SocketAcceptor',
'Quickfix::Message',
'Quickfix::Field',
'Quickfix::Group',
'Quickfix::MessageFactory',
'Quickfix::DataDictionaryProvider',
]
missing = []
classes_to_test.each do |class_name|
begin
Object.const_get(class_name.split('::'))
puts " ✓ #{class_name}"
rescue NameError
missing << class_name
end
end
if missing.empty?
puts ""
puts "All core classes available!"
exit 0
else
puts ""
puts "Missing classes: #{missing.join(', ')}"
exit 1
end
rescue LoadError => e
puts "Error: Failed to load quickfix: #{e.message}"
exit 1
end
EOF
if ruby "$TEST_SCRIPT"; then
echo "✓ Core QuickFIX classes are available"
else
echo "✗ Failed to verify core classes"
rm -f "$TEST_SCRIPT"
exit 1
fi
rm -f "$TEST_SCRIPT"
# Test 3: Check native extension
echo ""
echo "Test 3: Checking native extension..."
TEST_SCRIPT=$(mktemp)
cat > "$TEST_SCRIPT" << 'EOF'
begin
require 'quickfix'
# Try to create a simple message
msg = Quickfix::Message.new
# Try to set a field
field = Quickfix::Field(35)
msg.setField(field, 'D')
puts "✓ Native extension working"
exit 0
rescue => e
puts "✗ Error testing native extension: #{e.message}"
exit 1
end
EOF
if ruby "$TEST_SCRIPT"; then
echo "✓ Native extension is functional"
else
echo "✗ Native extension test failed"
rm -f "$TEST_SCRIPT"
exit 1
fi
rm -f "$TEST_SCRIPT"
echo ""
echo "=== Validation Complete ==="
echo ""
echo "✓ All validation tests PASSED!"
echo ""
echo "Package Summary:"
echo " Package: quickfix_ruby"
echo " Version: $GEM_VERSION"
echo " Status: Installed and functional"
echo " Repository: $SERVER_NAME"
echo ""
echo "The gem is working correctly!"