@@ -123,20 +123,42 @@ public void disableLogging()
123
123
* This instance of dub should not read any environment variables,
124
124
* nor should it do any file IO, to make it usable and reliable in unittests.
125
125
* Currently it reads environment variables but does not read the configuration.
126
+ *
127
+ * Note that since the design of Dub was centered on the file system for so long,
128
+ * `NativePath` is still a core part of how one interacts with this class.
129
+ * In order to be as close to the production code as possible, this class
130
+ * use the following conventions:
131
+ * - The project is located under `/dub/project/`;
132
+ * - The user and system packages are under `/dub/user/packages/` and
133
+ * `/dub/system/packages/`, respectively;
134
+ * Those paths don't need to exists, but they are what one might see
135
+ * when writing and debugging unittests.
126
136
*/
127
137
public class TestDub : Dub
128
138
{
139
+ // / Convenience constants for use in unittets
140
+ public static immutable ProjectPath = " /dub/project/" ;
141
+ // / Ditto
142
+ public static immutable SpecialDirs Paths = {
143
+ temp: " /dub/temp/" ,
144
+ systemSettings: " /dub/system/" ,
145
+ userSettings: " /dub/user/" ,
146
+ userPackages: " /dub/user/" ,
147
+ cache: " /dub/user/cache/" ,
148
+ };
149
+
129
150
// / Forward to base constructor
130
- public this (string root = " ." , PackageSupplier[] extras = null ,
131
- SkipPackageSuppliers skip = SkipPackageSuppliers.none)
151
+ public this (string root = ProjectPath,
152
+ PackageSupplier[] extras = null ,
153
+ SkipPackageSuppliers skip = SkipPackageSuppliers.none)
132
154
{
133
155
super (root, extras, skip);
134
156
}
135
157
136
158
// / Avoid loading user configuration
137
159
protected override Settings loadConfig (ref SpecialDirs dirs) const
138
160
{
139
- // No-op
161
+ dirs = Paths;
140
162
return Settings.init;
141
163
}
142
164
@@ -252,10 +274,10 @@ package class TestPackageManager : PackageManager
252
274
253
275
this ()
254
276
{
255
- NativePath pkg = NativePath(" /tmp/dub-testsuite-nonexistant/packages/ " );
256
- NativePath user = NativePath( " /tmp/dub-testsuite-nonexistant/user/ " ) ;
257
- NativePath system = NativePath( " /tmp/dub-testsuite-nonexistant/system/ " ) ;
258
- super (pkg , user, system, false );
277
+ NativePath local = NativePath(TestDub.ProjectPath );
278
+ NativePath user = TestDub.Paths.userSettings ;
279
+ NativePath system = TestDub.Paths.systemSettings ;
280
+ super (local , user, system, false );
259
281
}
260
282
261
283
// / Disabled as semantic are not implementable unless a virtual FS is created
0 commit comments