mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-18 10:14:34 +00:00
fix(test): run bucket paths explicitly
This commit is contained in:
1 parent
7e6e12d008
commit
27c8a9570b
12 files changed
+668
-304
No files matched your search
@@ -10,7 +10,12 @@ const GlmtTransformer = require('../../../dist/glmt/glmt-transformer').default;
|
||||
* Manual test for debug mode file logging
|
||||
*/
|
||||
|
||||
const logDir = path.join(os.homedir(), '.ccs', 'logs');
|
||||
const testRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ccs-debug-mode-test-'));
|
||||
const logDir = path.join(testRoot, 'logs');
|
||||
|
||||
process.on('exit', () => {
|
||||
fs.rmSync(testRoot, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
// Clean up any existing logs
|
||||
console.log('Cleaning up existing logs...');
|
||||
@@ -20,12 +25,12 @@ if (fs.existsSync(logDir)) {
|
||||
|
||||
console.log('\n=== Test 1: Debug Mode OFF (default) ===');
|
||||
{
|
||||
const transformer = new GlmtTransformer({ verbose: false });
|
||||
const transformer = new GlmtTransformer({ verbose: false, debugLogDir: logDir });
|
||||
console.log(`Debug logging: ${transformer.debugLog}`);
|
||||
|
||||
const input = {
|
||||
model: 'claude-sonnet-4.5',
|
||||
messages: [{ role: 'user', content: 'Test without debug' }]
|
||||
messages: [{ role: 'user', content: 'Test without debug' }],
|
||||
};
|
||||
|
||||
const { openaiRequest } = transformer.transformRequest(input);
|
||||
@@ -33,15 +38,17 @@ console.log('\n=== Test 1: Debug Mode OFF (default) ===');
|
||||
const openaiResponse = {
|
||||
id: 'test-1',
|
||||
model: 'GLM-4.6',
|
||||
choices: [{
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: 'Response without debug',
|
||||
reasoning_content: 'Some reasoning...'
|
||||
choices: [
|
||||
{
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: 'Response without debug',
|
||||
reasoning_content: 'Some reasoning...',
|
||||
},
|
||||
finish_reason: 'stop',
|
||||
},
|
||||
finish_reason: 'stop'
|
||||
}],
|
||||
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 }
|
||||
],
|
||||
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
|
||||
};
|
||||
|
||||
transformer.transformResponse(openaiResponse, {});
|
||||
@@ -59,13 +66,13 @@ console.log('\n=== Test 1: Debug Mode OFF (default) ===');
|
||||
|
||||
console.log('\n=== Test 2: Debug Mode ON (via config) ===');
|
||||
{
|
||||
const transformer = new GlmtTransformer({ verbose: true, debugLog: true });
|
||||
const transformer = new GlmtTransformer({ verbose: true, debugLog: true, debugLogDir: logDir });
|
||||
console.log(`Debug logging: ${transformer.debugLog}`);
|
||||
console.log(`Log directory: ${transformer.debugLogDir}`);
|
||||
|
||||
const input = {
|
||||
model: 'claude-sonnet-4.5',
|
||||
messages: [{ role: 'user', content: 'Test with debug' }]
|
||||
messages: [{ role: 'user', content: 'Test with debug' }],
|
||||
};
|
||||
|
||||
const { openaiRequest } = transformer.transformRequest(input);
|
||||
@@ -73,15 +80,17 @@ console.log('\n=== Test 2: Debug Mode ON (via config) ===');
|
||||
const openaiResponse = {
|
||||
id: 'test-2',
|
||||
model: 'GLM-4.6',
|
||||
choices: [{
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: 'Response with debug',
|
||||
reasoning_content: 'Detailed reasoning process for debugging...'
|
||||
choices: [
|
||||
{
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: 'Response with debug',
|
||||
reasoning_content: 'Detailed reasoning process for debugging...',
|
||||
},
|
||||
finish_reason: 'stop',
|
||||
},
|
||||
finish_reason: 'stop'
|
||||
}],
|
||||
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 }
|
||||
],
|
||||
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
|
||||
};
|
||||
|
||||
transformer.transformResponse(openaiResponse, {});
|
||||
@@ -105,10 +114,10 @@ console.log('\n=== Test 2: Debug Mode ON (via config) ===');
|
||||
}
|
||||
|
||||
// Check file names
|
||||
const hasRequestAnthropic = files.some(f => f.includes('request-anthropic'));
|
||||
const hasRequestOpenai = files.some(f => f.includes('request-openai'));
|
||||
const hasResponseOpenai = files.some(f => f.includes('response-openai'));
|
||||
const hasResponseAnthropic = files.some(f => f.includes('response-anthropic'));
|
||||
const hasRequestAnthropic = files.some((f) => f.includes('request-anthropic'));
|
||||
const hasRequestOpenai = files.some((f) => f.includes('request-openai'));
|
||||
const hasResponseOpenai = files.some((f) => f.includes('response-openai'));
|
||||
const hasResponseAnthropic = files.some((f) => f.includes('response-anthropic'));
|
||||
|
||||
console.log(`\nFile types found:`);
|
||||
console.log(` request-anthropic: ${hasRequestAnthropic ? '✓' : '✗'}`);
|
||||
@@ -122,25 +131,27 @@ console.log('\n=== Test 2: Debug Mode ON (via config) ===');
|
||||
}
|
||||
|
||||
// Check file contents
|
||||
const responseOpenaiFile = files.find(f => f.includes('response-openai'));
|
||||
const responseOpenaiFile = files.find((f) => f.includes('response-openai'));
|
||||
const responseOpenaiPath = path.join(logDir, responseOpenaiFile);
|
||||
const responseOpenaiData = JSON.parse(fs.readFileSync(responseOpenaiPath, 'utf8'));
|
||||
|
||||
console.log(`\nChecking response-openai.json for reasoning_content...`);
|
||||
if (responseOpenaiData.choices[0].message.reasoning_content) {
|
||||
console.log('✓ reasoning_content found in response-openai.json');
|
||||
console.log(` Length: ${responseOpenaiData.choices[0].message.reasoning_content.length} chars`);
|
||||
console.log(
|
||||
` Length: ${responseOpenaiData.choices[0].message.reasoning_content.length} chars`
|
||||
);
|
||||
} else {
|
||||
console.log('ERROR: reasoning_content NOT found in response-openai.json!');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const responseAnthropicFile = files.find(f => f.includes('response-anthropic'));
|
||||
const responseAnthropicFile = files.find((f) => f.includes('response-anthropic'));
|
||||
const responseAnthropicPath = path.join(logDir, responseAnthropicFile);
|
||||
const responseAnthropicData = JSON.parse(fs.readFileSync(responseAnthropicPath, 'utf8'));
|
||||
|
||||
console.log(`\nChecking response-anthropic.json for thinking block...`);
|
||||
const thinkingBlock = responseAnthropicData.content.find(b => b.type === 'thinking');
|
||||
const thinkingBlock = responseAnthropicData.content.find((b) => b.type === 'thinking');
|
||||
if (thinkingBlock) {
|
||||
console.log('✓ Thinking block found in response-anthropic.json');
|
||||
console.log(` Length: ${thinkingBlock.thinking.length} chars`);
|
||||
@@ -158,12 +169,12 @@ console.log('\n=== Test 3: Debug Mode via CCS_DEBUG=1 ===');
|
||||
fs.rmSync(logDir, { recursive: true, force: true });
|
||||
|
||||
process.env.CCS_DEBUG = '1';
|
||||
const transformer = new GlmtTransformer({ verbose: false });
|
||||
const transformer = new GlmtTransformer({ verbose: false, debugLogDir: logDir });
|
||||
console.log(`Debug logging: ${transformer.debugLog}`);
|
||||
|
||||
const input = {
|
||||
model: 'claude-sonnet-4.5',
|
||||
messages: [{ role: 'user', content: 'Test with env var' }]
|
||||
messages: [{ role: 'user', content: 'Test with env var' }],
|
||||
};
|
||||
|
||||
transformer.transformRequest(input);
|
||||
@@ -171,15 +182,17 @@ console.log('\n=== Test 3: Debug Mode via CCS_DEBUG=1 ===');
|
||||
const openaiResponse = {
|
||||
id: 'test-3',
|
||||
model: 'GLM-4.6',
|
||||
choices: [{
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: 'Response',
|
||||
reasoning_content: 'Reasoning...'
|
||||
choices: [
|
||||
{
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: 'Response',
|
||||
reasoning_content: 'Reasoning...',
|
||||
},
|
||||
finish_reason: 'stop',
|
||||
},
|
||||
finish_reason: 'stop'
|
||||
}],
|
||||
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 }
|
||||
],
|
||||
usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
|
||||
};
|
||||
|
||||
transformer.transformResponse(openaiResponse, {});
|
||||
@@ -211,14 +224,14 @@ console.log('\n=== Test 4: Error Handling (No Write Permission) ===');
|
||||
const transformer = new GlmtTransformer({
|
||||
debugLog: true,
|
||||
debugLogDir: readOnlyDir,
|
||||
verbose: false
|
||||
verbose: false,
|
||||
});
|
||||
|
||||
console.log('Testing graceful error handling with read-only directory...');
|
||||
|
||||
const input = {
|
||||
model: 'claude-sonnet-4.5',
|
||||
messages: [{ role: 'user', content: 'Test error handling' }]
|
||||
messages: [{ role: 'user', content: 'Test error handling' }],
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user