(t *testing.T)
| 354 | } |
| 355 | |
| 356 | func TestFormatErrorWithAbsolutePaths(t *testing.T) { |
| 357 | // Create a temporary directory and file |
| 358 | tmpDir := testutil.TempDir(t, "test-*") |
| 359 | tmpFile := filepath.Join(tmpDir, "test.md") |
| 360 | |
| 361 | err := CompilerError{ |
| 362 | Position: ErrorPosition{ |
| 363 | File: tmpFile, |
| 364 | Line: 5, |
| 365 | Column: 10, |
| 366 | }, |
| 367 | Type: "error", |
| 368 | Message: "invalid syntax", |
| 369 | } |
| 370 | |
| 371 | output := FormatError(err) |
| 372 | |
| 373 | // The output should contain test.md and line:column information |
| 374 | if !strings.Contains(output, "test.md:5:10:") { |
| 375 | t.Errorf("Expected output to contain file path with line:column, got: %s", output) |
| 376 | } |
| 377 | |
| 378 | // Since tmpDir is outside the working directory (in /tmp), the path should be absolute |
| 379 | // to avoid confusing relative paths with ".." components |
| 380 | lines := strings.Split(output, "\n") |
| 381 | if !strings.HasPrefix(lines[0], "/") { |
| 382 | t.Errorf("Expected output to start with absolute path for files outside working directory, got: %s", lines[0]) |
| 383 | } |
| 384 | |
| 385 | // Should contain error message |
| 386 | if !strings.Contains(output, "invalid syntax") { |
| 387 | t.Errorf("Expected output to contain error message, got: %s", output) |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | func TestClearScreen(t *testing.T) { |
| 392 | // ClearScreen should not panic when called |
nothing calls this directly
no test coverage detected