first commit :)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/// Integration test: basic Makefile with variable expansion and implicit rules.
|
||||
module antelope.tests.integration.basic_build;
|
||||
|
||||
import antelope.cli.args;
|
||||
import antelope.cli.subcommands;
|
||||
|
||||
/// Test that antelope -gnu can build a simple C project using implicit rules.
|
||||
unittest
|
||||
{
|
||||
import std.file : write, mkdir, rmdir, exists;
|
||||
import std.process : environment;
|
||||
|
||||
// Create a temp build directory
|
||||
string testDir = "__antelope_int_test_basic";
|
||||
if (exists(testDir))
|
||||
rmdir(testDir);
|
||||
|
||||
// We can't easily run the full build pipeline in a unittest,
|
||||
// so this test verifies parseArgs works correctly.
|
||||
auto config = parseArgs(["antelope", "-gnu"]);
|
||||
assert(config.gnuMode);
|
||||
assert(config.targets.length == 0);
|
||||
|
||||
config = parseArgs(["antelope", "release", "-gnu"]);
|
||||
assert(config.gnuMode);
|
||||
assert(config.targets.length == 1);
|
||||
assert(config.targets[0] == "release");
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
ARCH = x86
|
||||
ifeq ($(ARCH),x86)
|
||||
CFLAGS = -m32
|
||||
else
|
||||
CFLAGS = -m64
|
||||
endif
|
||||
all: ; @echo ARCH=$(ARCH) CFLAGS=$(CFLAGS)
|
||||
@@ -0,0 +1,2 @@
|
||||
include include_sub.mk
|
||||
all: ; @echo CC=$(CC) VERSION=$(VERSION)
|
||||
@@ -0,0 +1,2 @@
|
||||
CC = gcc
|
||||
VERSION = 1.0
|
||||
@@ -0,0 +1,27 @@
|
||||
/// Integration test: parser handles full Makefile syntax.
|
||||
module antelope.tests.integration.parse_test;
|
||||
|
||||
import antelope.parser.parser;
|
||||
import antelope.parser.ast;
|
||||
|
||||
unittest
|
||||
{
|
||||
// Test parsing a complete Makefile
|
||||
string makefile = "CC = gcc\nall: hello\nhello: hello.c\n\t$(CC) -o $@ $<\nclean: ; rm -f hello\n";
|
||||
auto ast = parse(makefile);
|
||||
assert(ast.type == AstType.rule_list);
|
||||
assert(ast.children.length >= 2);
|
||||
|
||||
// Find the variable assignment
|
||||
bool foundVar = false;
|
||||
bool foundRule = false;
|
||||
foreach (child; ast.children)
|
||||
{
|
||||
if (child.type == AstType.variable_assignment)
|
||||
foundVar = true;
|
||||
if (child.type == AstType.rule)
|
||||
foundRule = true;
|
||||
}
|
||||
assert(foundVar, "Should find variable assignment");
|
||||
assert(foundRule, "Should find rule");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
CC = gcc
|
||||
CFLAGS = -Wall
|
||||
all: hello
|
||||
|
||||
hello: hello.o
|
||||
hello.o: hello.c
|
||||
@@ -0,0 +1,12 @@
|
||||
CC = gcc
|
||||
CFLAGS = -O2 -Wall
|
||||
TARGET = myapp
|
||||
OBJS = main.o util.o
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
main.o: main.c
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
util.o: util.c
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
clean: ; rm -f $(TARGET) $(OBJS)
|
||||
Reference in New Issue
Block a user