Browse Source

Something? It's dark out, no?

Neia Finch 4 years ago
parent
commit
35aca499ff
2 changed files with 30 additions and 22 deletions
  1. 10
    5
      source/dubautotester/builder.d
  2. 20
    17
      source/dubautotester/commandline.d

+ 10
- 5
source/dubautotester/builder.d View File

@@ -10,10 +10,10 @@ import std.path;
10 10
 ProcessResult checkout(PackageRevision pkg, string dir)
11 11
 {
12 12
     ProcessResult pr;
13
-    if (!dir.exists || !chainPath(dir, ".git").exists)
13
+    mkdirRecurse(dir);
14
+    if (!chainPath(dir, ".git").exists)
14 15
     {
15 16
         auto parent = dirName(dir);
16
-        mkdirRecurse(parent);
17 17
         cd(parent);
18 18
         pr = clone(pkg.gitUrl, pkg.packageName);
19 19
         if (pr.status != 0) return pr;
@@ -49,6 +49,11 @@ Build build(Config config, PackageRevision revision)
49 49
 
50 50
     auto dir = config.dataDir.buildPath(revision.packageName);
51 51
     auto pr = checkout(revision, dir);
52
+    scope (exit)
53
+    {
54
+        import std.file : rmdirRecurse, exists;
55
+	if (exists(dir)) rmdirRecurse(dir);
56
+    }
52 57
     if (pr.status != 0)
53 58
     {
54 59
         result.stderr = cast(string)pr.stderr;
@@ -121,9 +126,9 @@ void buildAll(Config config, PackageRevision[] pkgs)
121 126
 
122 127
 void dubClean(Config config)
123 128
 {
124
-    import core.time : seconds;
125
-    infof("cleaning all dub packages to reduce disk usage");
126
-    run(120.seconds, config.dubLoc, "clean", "--all-packages");
129
+    import std.file : rmdirRecurse;
130
+    import std.path : expandTilde;
131
+    rmdirRecurse(expandTilde("~/.dub/packages"));
127 132
 }
128 133
 
129 134
 void exerciseRelease(Config config, string compilerRelease, void delegate() afterPackage)

+ 20
- 17
source/dubautotester/commandline.d View File

@@ -49,6 +49,10 @@ int runCommandLine(string[] args)
49 49
     {
50 50
         globalLogLevel = LogLevel.info;
51 51
     }
52
+    auto ml = new MultiLogger;
53
+    ml.insertLogger("stderr", sharedLog);
54
+    ml.insertLogger("file", new FileLogger("log"));
55
+    sharedLog = ml;
52 56
 
53 57
     config.init;
54 58
     scope (exit) config.die;
@@ -104,8 +108,7 @@ int runCommandLine(string[] args)
104 108
     import std.datetime.systime : Clock;
105 109
     import core.thread : Thread;
106 110
     import core.time : dur;
107
-    // Grab it on the second check.
108
-    auto nextGrab = Clock.currTime + dur!"minutes"(10);
111
+    auto nextGrab = SysTime.min;
109 112
     auto interval = dur!"hours"(1);
110 113
     foreach (i; 0..iterations)
111 114
     {
@@ -114,21 +117,6 @@ int runCommandLine(string[] args)
114 117
         {
115 118
             infof("compiler release %s found", r);
116 119
         }
117
-        infof("need to sleep until %s", nextGrab);
118
-        while (Clock.currTime < nextGrab)
119
-        {
120
-            Thread.sleep(dur!"seconds"(60));
121
-        }
122
-        nextGrab = Clock.currTime + interval;
123
-        if (!stalePackages)
124
-        {
125
-            infof("grabbing fresh packages");
126
-            auto pkgs = grabAllFresh(config);
127
-            config.importPackages(pkgs);
128
-            infof("have %s compiler releases and %s package revisions to test",
129
-                    compilerReleases.length, pkgs.length);
130
-        }
131
-        infof("going through the releases");
132 120
         long count = 0;
133 121
         foreach (release; compilerReleases)
134 122
         {
@@ -136,6 +124,7 @@ int runCommandLine(string[] args)
136 124
                 count++;
137 125
                 if (count >= 100)
138 126
                 {
127
+	            dubClean(config);
139 128
                     buildCompilerReports(config);
140 129
                     count = 0;
141 130
                 }
@@ -145,6 +134,20 @@ int runCommandLine(string[] args)
145 134
         }
146 135
         // doesn't hurt to do this every run
147 136
         buildCompilerReports(config);
137
+        if (!stalePackages)
138
+        {
139
+            infof("grabbing fresh packages");
140
+            auto pkgs = grabAllFresh(config);
141
+            config.importPackages(pkgs);
142
+            infof("have %s compiler releases and %s package revisions to test",
143
+                    compilerReleases.length, pkgs.length);
144
+        }
145
+        nextGrab = Clock.currTime + interval;
146
+        infof("need to sleep until %s", nextGrab);
147
+        while (Clock.currTime < nextGrab)
148
+        {
149
+            Thread.sleep(dur!"seconds"(60));
150
+        }
148 151
     }
149 152
     return 0;
150 153
 }