-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-init-script.mjs
More file actions
66 lines (54 loc) · 2.2 KB
/
test-init-script.mjs
File metadata and controls
66 lines (54 loc) · 2.2 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
#!/usr/bin/env node
/**
* T-Ruby 초기화 스크립트 생성 테스트
*
* 실제 생성되는 Ruby 초기화 스크립트를 확인
*/
import { readFileSync } from 'node:fs';
// dist/index.js에서 생성된 스크립트 추출
const distCode = readFileSync('./dist/index.js', 'utf-8');
// T_RUBY_INIT_SCRIPT 변수 찾기
// generateInitScript() 함수 결과를 찾아서 version.rb 로드 부분 확인
// T_RUBY_BUNDLE 추출
const bundleMatch = distCode.match(/var T_RUBY_BUNDLE = \{/);
if (!bundleMatch) {
console.error('T_RUBY_BUNDLE을 찾을 수 없음');
process.exit(1);
}
// version.rb 내용 찾기
const versionRbMatch = distCode.match(/"lib\/t_ruby\/version\.rb":\s*`([^`]*)`/);
if (versionRbMatch) {
console.log('=== version.rb 번들 내용 ===');
console.log(versionRbMatch[1]);
console.log('');
}
// generateInitScript 함수 시뮬레이션
// TRubyBundle.ts 소스에서 직접 확인
const bundleSource = readFileSync('./src/vm/TRubyBundle.ts', 'utf-8');
const initScriptSource = readFileSync('./src/vm/TRubyInitScript.ts', 'utf-8');
// version.rb 내용 추출
const versionRbInBundle = bundleSource.match(/"lib\/t_ruby\/version\.rb":\s*`([^`]*)`/);
if (versionRbInBundle) {
console.log('=== TRubyBundle.ts의 version.rb ===');
console.log(versionRbInBundle[1]);
console.log('');
}
// 생성된 스크립트에서 version.rb 로드 부분 시뮬레이션
console.log('=== 생성될 version.rb 로드 코드 ===');
const versionContent = versionRbInBundle ? versionRbInBundle[1] : '';
const processedContent = versionContent
.replace(/# frozen_string_literal: true\n?/g, '')
.replace(/require_relative\s+["'][^"']+["']\n?/g, '')
.replace(/require\s+["']fileutils["']\n?/g, '');
console.log(`puts "[T-Ruby WASM] Loading: lib/t_ruby/version.rb"
eval(<<~'__T_RUBY_CODE_0__', binding, 'lib/t_ruby/version.rb')
${processedContent}
__T_RUBY_CODE_0__
`);
// Ruby에서 이 스크립트가 TRuby::VERSION을 정의하는지 확인
console.log('=== 검증 ===');
if (processedContent.includes('module TRuby') && processedContent.includes('VERSION =')) {
console.log('✓ version.rb에 TRuby::VERSION 정의 존재');
} else {
console.log('✗ version.rb에 TRuby::VERSION 정의 없음');
}