Skip to content

Commit f5c009b

Browse files
committed
Add golden tests for this repo
Problem: we need to check if code changes will also change the behavior Solution: add test, that will make two derivations and check if output of program will be different of saved one.
1 parent 0fac3a8 commit f5c009b

File tree

9 files changed

+512
-3
lines changed

9 files changed

+512
-3
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ We can use `nix-diff` to compare the two computed derivations to determine what
7070
changed about our system:
7171

7272
```bash
73-
$ nix-diff /nix/store/6z9nr5pzs4j1v9mld517dmlcz61zy78z-nixos-system-nixos-18.03pre119245.5cfd049a03.drv /nix/store/k05ibijg0kknvwrgfyb7dxwjrs8qrlbj-nixos-system-nixos-18.03pre119245.5cfd049a03.drv
73+
$ nix-diff /nix/store/6z9nr5pzs4j1v9mld517dmlcz61zy78z-nixos-system-nixos-18.03pre119245.5cfd049a03.drv /nix/store/k05ibijg0kknvwrgfyb7dxwjrs8qrlbj-nixos-system-nixos-18.03pre119245.5cfd049a03.drv
7474
```
7575

7676
... which produces the following output:
@@ -83,6 +83,12 @@ It's also possible to pass store paths or links to store paths, for example:
8383
$ nix-build example.nix
8484
$ nix-diff /run/current-system ./result
8585
```
86+
## Testing
87+
88+
You have to have `nix-diff` in PATH to run test from `golden-tests` folder.
89+
You also have to be in that folder and to have nix in your system.
90+
91+
Basically, you can run test, using `cabal exec bash -- -c "cd golden-tests; ./run-test.sh"` command.
8692

8793
## Development status
8894

@@ -96,7 +102,7 @@ an improvement.
96102

97103
Copyright (c) 2017 Gabriella Gonzalez
98104
All rights reserved.
99-
105+
100106
Redistribution and use in source and binary forms, with or without modification,
101107
are permitted provided that the following conditions are met:
102108
* Redistributions of source code must retain the above copyright notice,
@@ -107,7 +113,7 @@ an improvement.
107113
* Neither the name of Gabriella Gonzalez nor the names of other contributors
108114
may be used to endorse or promote products derived from this software
109115
without specific prior written permission.
110-
116+
111117
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
112118
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
113119
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE

golden-tests/expected-output

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
- /nix/store/2bwmj0qp4m6fiah2b39qwpf1lw0l1a4v-drv.drv:{out}
2+
+ /nix/store/bg0lxf2d20a3sif8vpfmxcl6hch8ls8h-drv.drv:{out}
3+
• The arguments do not match
4+
• one
5+
- two
6+
• three
7+
+ four
8+
• The set of input source names do not match:
9+
- missing-file
10+
+ new-file
11+
• The input source named `changed-file` differs
12+
''
13+
When in the Course of human events it becomes necessary for one people to
14+
dissolve the political bands which have connected them with another and to
15+
assume among the powers of the earth, the separate and equal station to which
16+
the Laws of Nature and of Nature's ←God←→Dog→ entitle them, a decent respect to the
17+
opinions of mankind requires that they should declare the causes which impel
18+
them to the separation.
19+
We hold these truths to be self-evident, that all men are created equal, that
20+
they are endowed by their Creator with certain unalienable Rights, that among
21+
these are Life, Liberty and the pursuit of Happiness. — That to secure these
22+
rights, Governments are instituted among Men, deriving their just powers from
23+
the consent of the governed, — That whenever any Form of Government becomes
24+
destructive of these ends, it is the Right of the People to alter or to
25+
abolish it, and to institute new Government, laying its foundation on such
26+
principles and organizing its powers in such form, as to them shall seem most
27+
likely to effect their Safety and Happiness. Prudence, indeed, will dictate
28+
that Governments long established should not be changed for light and
29+
transient causes; and accordingly all experience hath shewn that mankind are
30+
more disposed to suffer, while evils are sufferable than to right themselves
31+
by abolishing the forms to which they are accustomed. But when a long train of
32+
abuses and usurpations, pursuing invariably the same Object evinces a design
33+
to reduce them under absolute Despotism, it is their right, it is their duty,
34+
to throw off such Government, and to provide new Guards for their future
35+
security. — Such has been the patient sufferance of these Colonies; and such
36+
is now the necessity which constrains them to alter their former Systems of
37+
Government. The history of the present King of Great Britain is a history of
38+
repeated injuries and usurpations, all having in direct object the
39+
establishment of an absolute Tyranny over these States. To prove this, let
40+
Facts be submitted to a candid world.
41+
He has refused his Assent to Laws, the most wholesome and necessary for the
42+
public good.
43+
He has forbidden his Governors to pass Laws of immediate and pressing
44+
importance, unless suspended in their operation till his Assent should be
45+
obtained; and when so suspended, he has utterly neglected to attend to them.
46+
He has refused to pass other Laws for the accommodation of large districts of
47+
people, unless those people would relinquish the right of Representation in
48+
the Legislature, a right inestimable to them and formidable to tyrants only.
49+
He has called together legislative bodies at places unusual, uncomfortable,
50+
and distant from the depository of their Public Records, for the sole purpose
51+
of fatiguing them into compliance with his measures.
52+
He has dissolved Representative Houses repeatedly, for opposing with manly
53+
firmness his invasions on the rights of the people.
54+
He has refused for a long time, after such dissolutions, to cause others to be
55+
elected, whereby the Legislative Powers, incapable of Annihilation, have
56+
returned to the People at large for their exercise; the State remaining in the
57+
mean time exposed to all the dangers of invasion from without, and convulsions
58+
within.
59+
He has endeavoured to prevent the population of these States; for that purpose
60+
obstructing the Laws for Naturalization of Foreigners; refusing to pass others
61+
to encourage their migrations hither, and raising the conditions of new
62+
Appropriations of Lands.
63+
He has obstructed the Administration of Justice by refusing his Assent to Laws
64+
for establishing Judiciary Powers.
65+
He has made Judges dependent on his Will alone for the tenure of their
66+
offices, and the amount and payment of their salaries.
67+
He has erected a multitude of New Offices, and sent hither swarms of Officers
68+
to harass our people and eat out their substance.
69+
He has kept among us, in times of peace, Standing Armies without the Consent
70+
of our legislatures.
71+
He has affected to render the Military independent of and superior to the
72+
Civil Power.
73+
He has combined with others to subject us to a jurisdiction foreign to our
74+
constitution, and unacknowledged by our laws; giving his Assent to their Acts
75+
of pretended Legislation:
76+
For quartering large bodies of armed troops among us:
77+
For protecting them, by a mock Trial from punishment for any Murders which
78+
they should commit on the Inhabitants of these States:
79+
For cutting off our Trade with all parts of the world:
80+
For imposing Taxes on us without our Consent:
81+
For depriving us in many cases, of the benefit of Trial by Jury:
82+
For transporting us beyond Seas to be tried for pretended offences:
83+
For abolishing the free System of English Laws in a neighbouring Province,
84+
establishing therein an Arbitrary government, and enlarging its Boundaries so
85+
as to render it at once an example and fit instrument for introducing the same
86+
absolute rule into these Colonies
87+
For taking away our Charters, abolishing our most valuable Laws and altering
88+
fundamentally the Forms of our Governments:
89+
For suspending our own Legislatures, and declaring themselves invested with
90+
power to legislate for us in all cases whatsoever.
91+
He has abdicated Government here, by declaring us out of his Protection and
92+
waging War against us.
93+
He has plundered our seas, ravaged our coasts, burnt our towns, and destroyed
94+
the lives of our people.
95+
He is at this time transporting large Armies of foreign Mercenaries to
96+
compleat the works of death, desolation, and tyranny, already begun with
97+
circumstances of Cruelty & Perfidy scarcely paralleled in the most barbarous
98+
ages, and totally unworthy the Head of a civilized nation.
99+
He has constrained our fellow Citizens taken Captive on the high Seas to bear
100+
Arms against their Country, to become the executioners of their friends and
101+
Brethren, or to fall themselves by their Hands.
102+
He has excited domestic insurrections amongst us, and has endeavoured to bring
103+
on the inhabitants of our frontiers, the merciless Indian Savages whose known
104+
rule of warfare, is an undistinguished destruction of all ages, sexes and
105+
conditions.
106+
In every stage of these Oppressions We have Petitioned for Redress in the most
107+
humble terms: Our repeated Petitions have been answered only by repeated
108+
injury. A Prince, whose character is thus marked by every act which may
109+
define a Tyrant, is unfit to be the ruler of a free people.
110+
Nor have We been wanting in attentions to our British brethren. We have warned
111+
them from time to time of attempts by their legislature to extend an
112+
unwarrantable jurisdiction over us. We have reminded them of the circumstances
113+
of our emigration and settlement here. We have appealed to their native
114+
justice and magnanimity, and we have conjured them by the ties of our common
115+
kindred to disavow these usurpations, which would inevitably interrupt our
116+
connections and correspondence. They too have been deaf to the voice of
117+
justice and of consanguinity. We must, therefore, acquiesce in the necessity,
118+
which denounces our Separation, and hold them, as we hold the rest of mankind,
119+
Enemies in War, in Peace Friends.
120+
We, therefore, the Representatives of the united States of America, in General
121+
Congress, Assembled, appealing to the Supreme Judge of the world for the
122+
rectitude of our intentions, do, in the Name, and by Authority of the good
123+
People of these Colonies, solemnly publish and declare, That these united
124+
Colonies are, and of Right ought to be Free and Independent States, that they
125+
are Absolved from all Allegiance to the British Crown, and that all political
126+
connection between them and the State of Great Britain, is and ought to be
127+
totally dissolved; and that as Free and Independent States, they have full
128+
Power to levy War, conclude Peace, contract Alliances, establish Commerce, and
129+
to do all other Acts and Things which Independent States may of right do. —
130+
And for the support of this Declaration, with a firm reliance on the
131+
protection of Divine Providence, we mutually pledge to each other our Lives,
132+
our Fortunes, and our sacred Honor.
133+
''
134+
• The set of input derivation names do not match:
135+
- old
136+
+ new
137+
• The set of input derivations named `outputs` do not match
138+
- /nix/store/sapk625xl072bdh8w7w7l3m1ii9lcc65-outputs.drv:{out}
139+
+ /nix/store/vsfl2bqr1banhcpwf0f3aja5320ijiln-outputs.drv:{lib}
140+
• The input derivation named `second_derivation` differs
141+
- /nix/store/gq9mz7fsvxanbpw6m4qlriyxzj6j7id8-second_derivation.drv:{out}
142+
+ /nix/store/0ijwj4k5vdyawhk12yghx3cdsic6w8ly-second_derivation.drv:{out}
143+
• The input derivation named `soft_from_SW` differs
144+
- /nix/store/f62l132ax7syr3l9y7y2413lmynq7wnh-soft_from_SW.drv:{out}
145+
+ /nix/store/vyks8xqgrydzay393gjz4bkah9c75892-soft_from_SW.drv:{out}
146+
• The platforms do not match
147+
- R2D2_astrodroid
148+
+ C3PO
149+
• The builders do not match
150+
- Anakin Skywalker
151+
+ Luke Skywalker
152+
• The environments do not match:
153+
- missingEnvVaribale=value
154+
+ newEnvVaribale=value
155+
• The environments do not match:
156+
derivations=''
157+
←/nix/store/6hhm9alara3lijwww2sbm8bmf81x5j94-soft_from_SW←→/nix/store/qrn9pa2j5swdqld8h0rhlvpj5mjcbn5z-soft_from_SW→
158+
''
159+
• The input derivation named `third_derivation` differs
160+
- /nix/store/j1jmbxd74kzianaywml2nw1ja31a00r5-third_derivation.drv:{out}
161+
+ /nix/store/ww51c2dha7m5l5qjzh2rblicsamkrh62-third_derivation.drv:{out}
162+
• The input derivation named `soft_from_SW` differs
163+
• These two derivations have already been compared
164+
• The environments do not match:
165+
derivations=''
166+
←/nix/store/6hhm9alara3lijwww2sbm8bmf81x5j94-soft_from_SW←→/nix/store/qrn9pa2j5swdqld8h0rhlvpj5mjcbn5z-soft_from_SW→
167+
''
168+
• The environments do not match:
169+
derivations=''
170+
←/nix/store/9dmp71si62hsgf2bi5g1ibkqdbwsv0zv-second_derivation←← ←←/nix/store/gvvxj52wd0s986ybx06gzrj8r2623fi9-third_derivation←← ←←/nix/store/5agf2p8f84fijdnlqy5mvwza3s2lic8l-old←← ←←/nix/store/10gqfacshzjzz0aayx29w5wrbcsbsa83-outputs←→/nix/store/1zy94ghyzk4f1r3alk4yhk2yvrm6x4ch-second_derivation→→ →→/nix/store/0xq8xmcxshwkai4rn55zb780pq8qdrbx-third_derivation→→ →→/nix/store/gz8x5pzvn6wpzk74m5nr7758iz8cvbsr-new→→ →→/nix/store/kqgpkfil6919d95c2vfyvdpb0fcfam30-outputs-lib→
171+
''
172+
srcs=''
173+
←/nix/store/271h6y1jg7qizbqav8a34bhdaa6lvd64-changed-file←→/nix/store/7xawqkhd7p3d0brazmrv5zi8ki9w64wk-changed-file→ ←/nix/store/w1cqaspljnya9vxwyv25m6ak2crqjy7i-missing-file←→/nix/store/h9jy4njbp943nffs7sc9ycndmxmvgwwa-new-file→
174+
''

0 commit comments

Comments
 (0)