Skip to content

Commit

Permalink
Fixed tests orders
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-balades committed Dec 22, 2023
1 parent 6540d6a commit 1fe954f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/builder/llvm/LLVMBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ llvm::DIFile* LLVMBuilder::DebugInfo::getFile(const std::string& path) {
void LLVMBuilder::dump() { this->print(llvm::errs()); }
void LLVMBuilder::print(llvm::raw_fd_ostream& s) { module->print(s, nullptr); }

#define ITERATE_FUNCTIONS for (auto fn = functions.rbegin(); fn != functions.rend(); ++fn)
#define ITERATE_FUNCTIONS for (auto fn = functions.begin(); fn != functions.end(); ++fn)
#define ITERATE_RFUNCTIONS for (auto fn = functions.rbegin(); fn != functions.rend(); ++fn)
void LLVMBuilder::codegen() {
auto generateModule = [&](std::shared_ptr<ir::Module> m, bool build) {
// reset context
Expand Down Expand Up @@ -251,7 +252,7 @@ void LLVMBuilder::codegen() {
// are bodied. We do 2 loops in order to prevent any weird
// situation when a function calls an undefined function that
// has not been generated yet.
ITERATE_FUNCTIONS {
ITERATE_RFUNCTIONS {
auto f = fn->get();
if (!f->isDeclaration() && !f->hasAttribute(Attributes::BUILTIN)) {
auto llvmFn = funcs.at(f->getId());
Expand Down
4 changes: 2 additions & 2 deletions src/builder/llvm/LLVMBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class LLVMBuilderContext {
// A value used to store a value into a variable
llvm::Value* callStoreValue = nullptr;
// A map of test functions containing their names
std::map<std::shared_ptr<ir::Func>, llvm::Function*> tests;
std::vector<std::pair<ir::Func*, llvm::Function*>> tests;
// A map of benchmark functions containing their names
std::map<std::shared_ptr<ir::Func>, llvm::Function*> benchmarks;
std::vector<std::pair<ir::Func*, llvm::Function*>> benchmarks;
// If the module is compiled in test mode
bool testMode = false;
// If the module is compiled in benchmark mode
Expand Down
4 changes: 2 additions & 2 deletions src/builder/llvm/buildFunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ void LLVMBuilder::visit(ir::Func* func) {
auto fn = createLLVMFunction(func);
if (func->hasAttribute(Attributes::ALLOW_FOR_TEST)) {
fn->addFnAttr(llvm::Attribute::NoInline);
ctx->tests.insert(std::make_pair(func, fn));
ctx->tests.push_back(std::make_pair(func, fn));
} else if (func->hasAttribute(Attributes::ALLOW_FOR_BENCH)) {
fn->addFnAttr(llvm::Attribute::NoInline);
ctx->benchmarks.insert(std::make_pair(func, fn));
ctx->benchmarks.push_back(std::make_pair(func, fn));
}

funcs.insert({func->getId(), fn});
Expand Down
Empty file removed test-files.txt
Empty file.
2 changes: 1 addition & 1 deletion tests/files.sn
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func open_file() i32 {
return fs::exists(path) as i32;
}

@test(skip) // this executes BEFORE open_file?!?!?
@test
func remove() i32 {
const path: &Path = new Path("./test-files.txt");
fs::remove(path);
Expand Down

0 comments on commit 1fe954f

Please sign in to comment.