Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 799

Show
Ignore:
Timestamp:
12/12/10 06:30:52 (14 years ago)
Author:
braddr
Message:

Add support for the MODEL variable.
Fix the usage text of d_do_test to have linefeeds, oops.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/test/d_do_test.d

    r765 r799  
    11module d_do_test; 
    22 
    33import std.algorithm; 
    44import std.array; 
    55import std.conv; 
    66import std.exception; 
    77import std.file; 
    88import std.format; 
    99import std.process; 
    1010import std.random; 
    1111import std.stdio; 
    1212import std.string; 
    1313import core.sys.posix.sys.wait; 
    1414 
    1515void usage() 
    1616{ 
    17     writeln("d_do_test <input_dir> <test_name> <test_extension>
    18             "
    19             "   input_dir: one of: compilable, fail_compilation, runnable
    20             "   test_name: basename of test case to run" 
    21             "   test_extension: one of: d, html, or sh
    22             "
    23             "   example: d_do_test runnable pi d
    24             "
    25             "   relevant environment variables:
    26             "      ARGS:        set to execute all combinations of
    27             "      DMD:         compiler to use, ex: ../src/dmd
    28             "      OS:          win32, linux, freebsd, osx
    29             "      RESULTS_DIR: base directory for test results
    30             "   windows vs non-windows portability env vars:
    31             "      DSEP:        \\\\ or /
    32             "      SEP:         \\ or /
    33             "      OBJ:        .obj or .o
    34             "      EXE:        .exe or <null>"); 
     17    write("d_do_test <input_dir> <test_name> <test_extension>\n
     18          "\n
     19          "   input_dir: one of: compilable, fail_compilation, runnable\n
     20          "   test_name: basename of test case to run\n" 
     21          "   test_extension: one of: d, html, or sh\n
     22          "\n
     23          "   example: d_do_test runnable pi d\n
     24          "\n
     25          "   relevant environment variables:\n
     26          "      ARGS:        set to execute all combinations of\n
     27          "      DMD:         compiler to use, ex: ../src/dmd\n
     28          "      OS:          win32, linux, freebsd, osx\n
     29          "      RESULTS_DIR: base directory for test results\n
     30          "   windows vs non-windows portability env vars:\n
     31          "      DSEP:        \\\\ or /\n
     32          "      SEP:         \\ or /\n
     33          "      OBJ:        .obj or .o\n
     34          "      EXE:        .exe or <null>\n"); 
    3535} 
    3636 
    3737enum TestMode 
    3838{ 
    3939    COMPILE, 
    4040    FAIL_COMPILE, 
    4141    RUN 
    4242} 
    4343 
    4444struct TestArgs 
    4545{ 
    4646    TestMode mode; 
    4747 
    4848    bool     compileSeparately; 
    4949    string   executeArgs; 
    5050    string[] sources; 
    5151    string   permuteArgs; 
    5252    string   postScript; 
    5353    string   requiredArgs; 
    5454} 
    5555 
    5656struct EnvData 
    5757{ 
    5858    string all_args; 
    5959    string dmd; 
    6060    string results_dir; 
    6161    string sep; 
    6262    string dsep; 
    6363    string obj; 
    6464    string exe; 
    6565    string os; 
     66    string model; 
    6667} 
    6768 
    6869bool findTestParameter(string file, string token, ref string result) 
    6970{ 
    7071    auto tokenStart = std.string.indexOf(file, token); 
    7172    if (tokenStart == -1) return false; 
    7273 
    7374    auto lineEndR = std.string.indexOf(file[tokenStart .. $], "\r"); 
    7475    auto lineEndN = std.string.indexOf(file[tokenStart .. $], "\n"); 
    7576    auto lineEnd  = lineEndR == -1 ? 
    7677        (lineEndN == -1 ? file.length : lineEndN) : 
    7778        (lineEndN == -1 ? lineEndR    : min(lineEndR, lineEndN)); 
    7879 
    7980    //writeln("found ", token, " in line: ", file.length, ", ", tokenStart, ", ", tokenStart+lineEnd); 
    8081    //writeln("found ", token, " in line: '", file[tokenStart .. tokenStart+lineEnd], "'"); 
    8182 
    8283    result = strip(file[tokenStart+token.length .. tokenStart+lineEnd]); 
    8384    // skips the :, if present 
    8485    if (result.length > 0 && result[0] == ':') 
    8586        result = strip(result[1 .. $]); 
     
    227228{ 
    228229    if (args.length != 4) 
    229230    { 
    230231        usage(); 
    231232        return 1; 
    232233    } 
    233234 
    234235    string input_dir      = args[1]; 
    235236    string test_name      = args[2]; 
    236237    string test_extension = args[3]; 
    237238 
    238239    EnvData envData; 
    239240    envData.all_args      = getenv("ARGS"); 
    240241    envData.results_dir   = getenv("RESULTS_DIR"); 
    241242    envData.sep           = getenv("SEP"); 
    242243    envData.dsep          = getenv("DSEP"); 
    243244    envData.obj           = getenv("OBJ"); 
    244245    envData.exe           = getenv("EXE"); 
    245246    envData.os            = getenv("OS"); 
    246247    envData.dmd           = replace(getenv("DMD"), "/", envData.sep); 
     248    envData.model         = getenv("MODEL"); 
    247249 
    248250    string input_file     = input_dir ~ envData.sep ~ test_name ~ "." ~ test_extension; 
    249251    string output_dir     = envData.results_dir ~ envData.sep ~ input_dir; 
    250252    string output_file    = envData.results_dir ~ envData.sep ~ input_dir ~ envData.sep ~ test_name ~ "." ~ test_extension ~ ".out"; 
    251253    string test_app_dmd_base = output_dir ~ envData.sep ~ test_name ~ "_"; 
    252254 
    253255    TestArgs testArgs; 
    254256 
    255257    switch (input_dir) 
    256258    { 
    257259        case "compilable":       testArgs.mode = TestMode.COMPILE;      break; 
    258260        case "fail_compilation": testArgs.mode = TestMode.FAIL_COMPILE; break; 
    259261        case "runnable":         testArgs.mode = TestMode.RUN;          break; 
    260262    } 
    261263 
    262264    gatherTestParameters(testArgs, input_dir, input_file, envData); 
    263265 
    264266    writefln(" ... %-30s %s%s(%s)", 
    265267            input_file, 
    266268            testArgs.requiredArgs, 
     
    271273        std.file.remove(output_file); 
    272274 
    273275    auto f = File(output_file, "a"); 
    274276 
    275277    foreach(i, c; combinations(testArgs.permuteArgs)) 
    276278    { 
    277279        string[] toCleanup; 
    278280 
    279281        string test_app_dmd = test_app_dmd_base ~ to!string(i) ~ envData.exe; 
    280282 
    281283        try 
    282284        { 
    283285            if (!testArgs.compileSeparately) 
    284286            { 
    285287                string objfile = output_dir ~ envData.sep ~ test_name ~ "_" ~ to!string(i) ~ envData.obj; 
    286288                toCleanup ~= objfile; 
    287289 
    288290                if (testArgs.mode == TestMode.RUN) 
    289291                    toCleanup ~= test_app_dmd; 
    290292 
    291                 string command = format("%s -I%s %s %s -od%s -of%s %s%s", envData.dmd, input_dir, 
     293                string command = format("%s -m%s -I%s %s %s -od%s -of%s %s%s", envData.dmd, envData.model, input_dir, 
    292294                        testArgs.requiredArgs, c, output_dir, 
    293295                        (testArgs.mode == TestMode.RUN ? test_app_dmd : objfile), 
    294296                        (testArgs.mode == TestMode.RUN ? "" : "-c "), 
    295297                        join(testArgs.sources, " ")); 
    296298                version(Windows) command ~= " -map nul.map"; 
    297299                execute(f, command, testArgs.mode != TestMode.FAIL_COMPILE); 
    298300            } 
    299301            else 
    300302            { 
    301303                foreach (filename; testArgs.sources) 
    302304                { 
    303305                    string newo= envData.results_dir ~ envData.sep ~ 
    304306                        replace(replace(filename, ".d", envData.obj), envData.sep~"imports"~envData.sep, envData.sep); 
    305307                    toCleanup ~= newo; 
    306308 
    307                     string command = format("%s -I%s %s %s -od%s -c %s", envData.dmd, input_dir, 
     309                    string command = format("%s -m%s -I%s %s %s -od%s -c %s", envData.dmd, envData.model, input_dir, 
    308310                        testArgs.requiredArgs, c, output_dir, filename); 
    309311                    execute(f, command, testArgs.mode != TestMode.FAIL_COMPILE); 
    310312                } 
    311313 
    312314                if (testArgs.mode == TestMode.RUN) 
    313315                { 
    314316                    // link .o's into an executable 
    315                     string command = format("%s -od%s -of%s %s", envData.dmd, output_dir, test_app_dmd, join(toCleanup, " ")); 
     317                    string command = format("%s -m%s -od%s -of%s %s", envData.dmd, envData.model, output_dir, test_app_dmd, join(toCleanup, " ")); 
    316318                    version(Windows) command ~= " -map nul.map"; 
    317319 
    318320                    // add after building the command so that before now, it's purely the .o's involved 
    319321                    toCleanup ~= test_app_dmd; 
    320322 
    321323                    execute(f, command, true); 
    322324                } 
    323325            } 
    324326 
    325327            if (testArgs.mode == TestMode.RUN) 
    326328            { 
    327329                string command = test_app_dmd; 
    328330                if (testArgs.executeArgs) command ~= " " ~ testArgs.executeArgs; 
    329331 
    330332                execute(f, command, true); 
    331333            } 
    332334 
    333335            if (testArgs.postScript) 
    334336            { 
    335337                f.write("Executing post-test script: "); 
  • trunk/test/Makefile

    r679 r799  
    4848                OS:=freebsd 
    4949            else 
    5050                $(error Unrecognized or unsupported OS for uname: $(OS)) 
    5151            endif 
    5252        endif 
    5353    endif 
    5454else 
    5555    ifeq (Windows_NT,$(OS)) 
    5656    OS:=win32 
    5757    else 
    5858        ifeq (Win_32,$(OS)) 
    5959        OS:=win32 
    6060        endif 
    6161    endif 
    6262endif 
    6363export OS 
    6464 
    6565SHELL=/bin/bash 
    6666QUIET=@ 
    6767export RESULTS_DIR=test_results 
     68export MODEL=32 
    6869 
    6970ifeq ($(OS),win32) 
    7071export ARGS=-inline -release -g -O -unittest 
    7172export DMD=../src/dmd.exe 
    7273export EXE=.exe 
    7374export OBJ=.obj 
    7475export DSEP=\\ 
    7576export SEP=$(shell echo '\') 
    7677# bug in vim syntax hilighting, needed to kick it back into life: ') 
    7778else 
    7879export ARGS=-inline -release -gc -O -unittest -fPIC 
    7980export DMD=../src/dmd 
    8081export EXE= 
    8182export OBJ=.o 
    8283export DSEP=/ 
    8384export SEP=/ 
    8485endif 
    8586 
    8687runnable_tests=$(wildcard runnable/*.d) $(wildcard runnable/*.html) $(wildcard runnable/*.sh) 
    8788runnable_test_results=$(addsuffix .out,$(addprefix $(RESULTS_DIR)/,$(runnable_tests))) 
     
    130131run_runnable_tests: $(runnable_test_results) 
    131132 
    132133start_runnable_tests: $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test 
    133134    @echo "Running runnable tests" 
    134135    $(QUIET)$(MAKE) --no-print-directory run_runnable_tests 
    135136 
    136137run_compilable_tests: $(compilable_test_results) 
    137138 
    138139start_compilable_tests: $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test 
    139140    @echo "Running compilable tests" 
    140141    $(QUIET)$(MAKE) --no-print-directory run_compilable_tests 
    141142 
    142143run_fail_compilation_tests: $(fail_compilation_test_results) 
    143144 
    144145start_fail_compilation_tests: $(RESULTS_DIR)/.created $(RESULTS_DIR)/d_do_test 
    145146    @echo "Running fail compilation tests" 
    146147    $(QUIET)$(MAKE) --no-print-directory run_fail_compilation_tests 
    147148 
    148149$(RESULTS_DIR)/d_do_test: d_do_test.d $(RESULTS_DIR)/.created 
    149150    @echo "Building d_do_test tool" 
    150     $(QUIET)$(DMD) -od$(RESULTS_DIR) -of$(RESULTS_DIR)$(DSEP)d_do_test d_do_test.d 
     151    $(QUIET)$(DMD) -m$(MODEL) -od$(RESULTS_DIR) -of$(RESULTS_DIR)$(DSEP)d_do_test d_do_test.d 
    151152