Skip to content

Add test for herb_read_file#1127

Merged
marcoroth merged 1 commit intomarcoroth:mainfrom
citizen428:add-herb-read-file-test
Feb 6, 2026
Merged

Add test for herb_read_file#1127
marcoroth merged 1 commit intomarcoroth:mainfrom
citizen428:add-herb-read-file-test

Conversation

@citizen428
Copy link
Contributor

Document that the function exits when the filename is invalid.

Rationale:
I was originally a bit concerned when reading main.c that there was no NULL check around this line:

char* source = herb_read_file(argv[2]);

However, argv[2] should never be empty due to this check:

if (argc < 3) {
  printf("Please specify input file.\n");
  return 1;
}

This leaves the potential problem of non-existent files, which is handled directly inside herb_read_file. This behavior surprised me a little bit, so I thought it might be a good idea to document it with a test.

@github-actions github-actions bot added the c label Feb 6, 2026
$(cc) -c $(flags) -fPIC $< -o $@

test/%.o: test/%.c templates
test/%.o: test/%.c templates prism
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I needed to add prism as a dependency of the test target, otherwise make test could not complete after a make clean due to a missing Prism header.

Document that the function exits when the filename is invalid.
@citizen428 citizen428 force-pushed the add-herb-read-file-test branch from 7568987 to 6a5cbab Compare February 6, 2026 04:17
Copy link
Owner

@marcoroth marcoroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @citizen428! 🙏🏼

@marcoroth marcoroth merged commit 5c18934 into marcoroth:main Feb 6, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants