@@ -29,21 +29,18 @@ class FillInOutputPathsTest : public LibStoreTest, public JsonCharacterizationTe
2929 */
3030 StorePath makeCAFloatingDependency (std::string_view name)
3131 {
32- Derivation depDrv;
33- depDrv.name = name;
34- depDrv.platform = " x86_64-linux" ;
35- depDrv.builder = " /bin/sh" ;
36- depDrv.outputs = {
37- {
38- " out" ,
39- // will ensure that downstream is deferred
40- DerivationOutput{DerivationOutput::CAFloating{
41- .method = ContentAddressMethod::Raw::NixArchive,
42- .hashAlgo = HashAlgorithm::SHA256 ,
43- }},
44- },
32+ Derivation depDrv{
33+ .outputs =
34+ {{" out" ,
35+ DerivationOutput{DerivationOutput::CAFloating{
36+ .method = ContentAddressMethod::Raw::NixArchive,
37+ .hashAlgo = HashAlgorithm::SHA256 ,
38+ }}}},
39+ .platform = " x86_64-linux" ,
40+ .builder = " /bin/sh" ,
41+ .env = {{" out" , " " }},
42+ .name = std::string{name},
4543 };
46- depDrv.env = {{" out" , " " }};
4744
4845 // Fill in the dependency derivation's output paths
4946 depDrv.fillInOutputPaths (*store);
@@ -64,14 +61,13 @@ TEST_F(FillInOutputPathsTest, fillsDeferredOutputs_emptyStringEnvVar)
6461 using nlohmann::json;
6562
6663 // Before: Derivation with deferred output
67- Derivation drv;
68- drv. name = " filled-in-deferred-empty-env-var " ;
69- drv .platform = " x86_64-linux" ;
70- drv .builder = " /bin/sh" ;
71- drv. outputs = {
72- { " out " , DerivationOutput{DerivationOutput::Deferred{}}} ,
64+ Derivation drv{
65+ . outputs = {{ " out " , DerivationOutput{DerivationOutput::Deferred{}}}},
66+ .platform = " x86_64-linux" ,
67+ .builder = " /bin/sh" ,
68+ . env = {{ " __doc " , " Fill in deferred output with empty env var " }, { " out " , " " }},
69+ . name = " filled-in-deferred-empty-env-var " ,
7370 };
74- drv.env = {{" __doc" , " Fill in deferred output with empty env var" }, {" out" , " " }};
7571
7672 // Serialize before state
7773 checkpointJson (" filled-in-deferred-empty-env-var-pre" , drv);
@@ -95,15 +91,12 @@ TEST_F(FillInOutputPathsTest, fillsDeferredOutputs_empty_string_var)
9591 using nlohmann::json;
9692
9793 // Before: Derivation with deferred output
98- Derivation drv;
99- drv.name = " filled-in-deferred-no-env-var" ;
100- drv.platform = " x86_64-linux" ;
101- drv.builder = " /bin/sh" ;
102- drv.outputs = {
103- {" out" , DerivationOutput{DerivationOutput::Deferred{}}},
104- };
105- drv.env = {
106- {" __doc" , " Fill in deferred with missing env var" },
94+ Derivation drv{
95+ .outputs = {{" out" , DerivationOutput{DerivationOutput::Deferred{}}}},
96+ .platform = " x86_64-linux" ,
97+ .builder = " /bin/sh" ,
98+ .env = {{" __doc" , " Fill in deferred with missing env var" }},
99+ .name = " filled-in-deferred-no-env-var" ,
107100 };
108101
109102 // Serialize before state
@@ -127,16 +120,12 @@ TEST_F(FillInOutputPathsTest, preservesInputAddressedOutputs)
127120{
128121 auto expectedPath = StorePath{" w4bk7hpyxzgy2gx8fsa8f952435pll3i-filled-in-already" };
129122
130- Derivation drv;
131- drv.name = " filled-in-already" ;
132- drv.platform = " x86_64-linux" ;
133- drv.builder = " /bin/sh" ;
134- drv.outputs = {
135- {" out" , DerivationOutput{DerivationOutput::InputAddressed{.path = expectedPath}}},
136- };
137- drv.env = {
138- {" __doc" , " Correct path stays unchanged" },
139- {" out" , store->printStorePath (expectedPath)},
123+ Derivation drv{
124+ .outputs = {{" out" , DerivationOutput{DerivationOutput::InputAddressed{.path = expectedPath}}}},
125+ .platform = " x86_64-linux" ,
126+ .builder = " /bin/sh" ,
127+ .env = {{" __doc" , " Correct path stays unchanged" }, {" out" , store->printStorePath (expectedPath)}},
128+ .name = " filled-in-already" ,
140129 };
141130
142131 // Serialize before state
@@ -154,16 +143,12 @@ TEST_F(FillInOutputPathsTest, throwsOnIncorrectInputAddressedPath)
154143{
155144 auto wrongPath = StorePath{" c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-wrong-name" };
156145
157- Derivation drv;
158- drv.name = " bad-path" ;
159- drv.platform = " x86_64-linux" ;
160- drv.builder = " /bin/sh" ;
161- drv.outputs = {
162- {" out" , DerivationOutput{DerivationOutput::InputAddressed{.path = wrongPath}}},
163- };
164- drv.env = {
165- {" __doc" , " Wrong InputAddressed path throws error" },
166- {" out" , store->printStorePath (wrongPath)},
146+ Derivation drv{
147+ .outputs = {{" out" , DerivationOutput{DerivationOutput::InputAddressed{.path = wrongPath}}}},
148+ .platform = " x86_64-linux" ,
149+ .builder = " /bin/sh" ,
150+ .env = {{" __doc" , " Wrong InputAddressed path throws error" }, {" out" , store->printStorePath (wrongPath)}},
151+ .name = " bad-path" ,
167152 };
168153
169154 // Serialize before state
@@ -177,16 +162,12 @@ TEST_F(FillInOutputPathsTest, throwsOnIncorrectEnvVar)
177162{
178163 auto wrongPath = StorePath{"c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-wrong-name"};
179164
180- Derivation drv;
181- drv.name = "bad-env-var";
182- drv.platform = "x86_64-linux";
183- drv.builder = "/bin/sh";
184- drv.outputs = {
185- {"out", DerivationOutput{DerivationOutput::Deferred{}}},
186- };
187- drv.env = {
188- {"__doc", "Wrong env var value throws error"},
189- {"out", store->printStorePath(wrongPath)},
165+ Derivation drv{
166+ .outputs = {{"out", DerivationOutput{DerivationOutput::Deferred{}}}},
167+ .platform = "x86_64-linux",
168+ .builder = "/bin/sh",
169+ .env = {{"__doc", "Wrong env var value throws error"}, {"out", store->printStorePath(wrongPath)}},
170+ .name = "bad-env-var",
190171 };
191172
192173 // Serialize before state
@@ -204,19 +185,14 @@ TEST_F(FillInOutputPathsTest, preservesDeferredWithInputDrvs)
204185 auto depDrvPath = makeCAFloatingDependency (" dependency" );
205186
206187 // Create a derivation that depends on the dependency
207- Derivation drv;
208- drv.name = " depends-on-drv" ;
209- drv.platform = " x86_64-linux" ;
210- drv.builder = " /bin/sh" ;
211- drv.outputs = {
212- {" out" , DerivationOutput{DerivationOutput::Deferred{}}},
213- };
214- drv.env = {
215- {" __doc" , " Deferred stays deferred with CA dependencies" },
216- {" out" , " " },
188+ Derivation drv{
189+ .outputs = {{" out" , DerivationOutput{DerivationOutput::Deferred{}}}},
190+ .inputs = {.drvs = {.map = {{depDrvPath, {.value = {" out" }}}}}},
191+ .platform = " x86_64-linux" ,
192+ .builder = " /bin/sh" ,
193+ .env = {{" __doc" , " Deferred stays deferred with CA dependencies" }, {" out" , " " }},
194+ .name = " depends-on-drv" ,
217195 };
218- // Add the real input derivation dependency
219- drv.inputs .drvs = {.map = {{depDrvPath, {.value = {" out" }}}}};
220196
221197 // Serialize before state
222198 checkpointJson (" depends-on-drv-pre" , drv);
@@ -240,19 +216,14 @@ TEST_F(FillInOutputPathsTest, throwsOnPatWhenShouldBeDeffered)
240216 auto wrongPath = StorePath{" c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-wrong-name" };
241217
242218 // Create a derivation that depends on the dependency
243- Derivation drv;
244- drv.name = " depends-on-drv" ;
245- drv.platform = " x86_64-linux" ;
246- drv.builder = " /bin/sh" ;
247- drv.outputs = {
248- {" out" , DerivationOutput{DerivationOutput::InputAddressed{.path = wrongPath}}},
249- };
250- drv.env = {
251- {" __doc" , " InputAddressed throws when should be deferred" },
252- {" out" , " " },
219+ Derivation drv{
220+ .outputs = {{" out" , DerivationOutput{DerivationOutput::InputAddressed{.path = wrongPath}}}},
221+ .inputs = {.drvs = {.map = {{depDrvPath, {.value = {" out" }}}}}},
222+ .platform = " x86_64-linux" ,
223+ .builder = " /bin/sh" ,
224+ .env = {{" __doc" , " InputAddressed throws when should be deferred" }, {" out" , " " }},
225+ .name = " depends-on-drv" ,
253226 };
254- // Add the real input derivation dependency
255- drv.inputs .drvs = {.map = {{depDrvPath, {.value = {" out" }}}}};
256227
257228 // Serialize before state
258229 checkpointJson (" bad-depends-on-drv-pre" , drv);
0 commit comments