This document describes how to run and maintain the test suite for the DuckDB for FreePascal Library.
- Lazarus 3.6 or higher
- FPC (Free Pascal Compiler) version 3.2.2 or higher, which includes
fpcunitpackage. - DuckDB library in
src/folder, on the same level astests/.
From the tests/ directory:
/path/to/Lazarus/lazbuild.exe DuckDB.FP.Tests.lpiFrom the tests/ directory:
./DuckDB.FP.Tests.exe -a --format=plainNote
-a= run all tests--format=plain= output in plain text--format=xml= output in XML format
Run a specific test case
./DuckDB.FP.Tests.exe --suite=TestDistinct --format=plainRun all tests in a specific test suite
./DuckDB.FP.Tests.exe --suite=TDuckDBDataFrameTest --format=plainThe test runner will output:
- Test progress
- Failed test details
- Test execution time
- Total tests run/passed/failed
tests/DuckDB.FP.Tests.pas: Main test suite
DuckDB.FreePascal.Cases.pas- Basic DataFrame operations
- Data type conversions
- Date/Time handling
- CSV import/export
- Column operations
- Test data is created in temporary directories
- Automatically cleaned up after tests complete
- Located in
FTempDirduring test execution
Note
- Test Case = individual test
- Test Suite = collection of test cases
type
TNewTestSuite = class(TTestCase)
private
// Private declarations here, including helper methods
protected
// Protected declarations here
procedure SetUp; override;
procedure TearDown; override;
published
// Add tests here
procedure TestNewFeature;
// Add more tests here
end;
implementation
// Implement Setup and TearDown here
procedure TNewTestSuite.TestNewFeature;
var
Frame: TDuckFrame;
begin
Frame := CreateSampleFrame;
try
// Your test code here
AssertEquals('Description', Expected, Actual);
finally
Frame.Free;
end;
end;
// Add more implementation of tests here
initialization
// Register the test suite
// If the test suite is in the same file, register it after TDuckDBDataFrameTest
RegisterTest(TDuckDBDataFrameTest);
RegisterTest(TNewTestSuite);
end.- Always use try-finally blocks
- Clean up resources (files, memory)
- Use meaningful test names
- Add comments explaining complex test scenarios
- One assertion per test when possible
- Always free TDuckFrame instances
- Use
try-finallyblocks - Clean up temporary files
- Be careful with date/time conversions
- Handle null values appropriately
- Check variant type conversions
- Use
FTempDirfor temporary files - Clean up in
TearDown - Handle file path differences between OS
-
"Column not found"
- Check column name case sensitivity
- Verify column exists in frame
-
"Invalid type conversion"
- Check data types match
- Verify variant type handling
-
"Memory leak detected"
- Look for missing Free calls
- Check try-finally blocks
- Check existing test cases for examples
- Open an issue on GitHub
- Write tests for new features
- Update tests for modified features
- Ensure all tests pass before submitting PR
- Add test cases for bug fixes
Number of run tests: 42
Number of errors: 10
Number of failures: 0
List of errors:
Error:
Message: TDuckDBDataFrameTest.TestCreateBlankMismatchedArrays: Column names and types arrays must have same length
Exception class: EDuckDBError
Exception message: Column names and types arrays must have same length
at $0000000100063922
Error:
Message: TDuckDBDataFrameTest.TestAddColumn: Column NewColumn already exists
Exception class: EDuckDBError
Exception message: Column NewColumn already exists
at $0000000100063A86
Error:
Message: TDuckDBDataFrameTest.TestAddRow: Number of values must match number of columns
Exception class: EDuckDBError
Exception message: Number of values must match number of columns
at $0000000100063C3E
Error:
Message: TDuckDBDataFrameTest.TestGetColumnByName: Column "NonExistentColumn" not found
Exception class: EDuckDBError
Exception message: Column "NonExistentColumn" not found
at $0000000100056EB6
Error:
Message: TDuckDBDataFrameTest.TestValuesByName: Row index out of range
Exception class: EDuckDBError
Exception message: Row index out of range
at $0000000100056F5E
Error:
Message: TDuckDBDataFrameTest.TestValues: Row index out of range
Exception class: EDuckDBError
Exception message: Row index out of range
at $0000000100056F5E
Error:
Message: TDuckDBDataFrameTest.TestInvalidColumnAccess: Column "NonExistentColumn" not found
Exception class: EDuckDBError
Exception message: Column "NonExistentColumn" not found
at $000000010005704D
Error:
Message: TDuckDBDataFrameTest.TestInvalidRowAccess: Row index out of range
Exception class: EDuckDBError
Exception message: Row index out of range
at $0000000100056F5E
Error:
Message: TDuckDBDataFrameTest.TestInvalidCSVFile: File not found: nonexistent.csv
Exception class: EDuckDBError
Exception message: File not found: nonexistent.csv
at $0000000100063630
Error:
Message: TDuckDBDataFrameTest.TestCreateFromParquetErrors: File not found: nonexistent.parquet
Exception class: EDuckDBError
Exception message: File not found: nonexistent.parquet
at $0000000100064354la
Last updated: 2024-11-12