Skip to content

Commit 436bd84

Browse files
authored
Remove site dependency in hxml target flag test (#668)
The `testInstallHxmlWithBackend` test require lib.haxe.org to be up so it can fetch the server's hxcpp version, which is not good if we are redeploying the server because it's down. The new test just tests the LibFlagData.fromHxml function directly, to ensure no duplication there. We could also add an integration test in future.
1 parent 232a080 commit 436bd84

File tree

5 files changed

+50
-23
lines changed

5 files changed

+50
-23
lines changed

test/HaxelibTests.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class HaxelibTests {
6969
r.add(new TestRemoveSymlinks());
7070
r.add(new TestRemoveSymlinksBroken());
7171
r.add(new TestInstaller());
72+
r.add(new TestLibFlagData());
7273
r.add(new TestRepoManager());
7374
r.add(new TestRepoReformatter());
7475
r.add(new TestRepoReformatterOnLocal());
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-cpp bin
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
-cpp bin
21
--cpp bin

test/tests/TestInstaller.hx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,6 @@ class TestInstaller extends TestBase {
7575
assertFalse(FileSystem.exists(Path.join([lib, "git", "README.md"])));
7676
}
7777

78-
public function testInstallHxmlWithBackend() {
79-
// inferred from -cpp/--cpp flags
80-
installer.installFromHxml("cpp.hxml", (libs) -> {
81-
assertEquals(1, Lambda.count(libs, (lib) -> lib.name == "hxcpp"));
82-
return false;
83-
});
84-
85-
// specified explicitly
86-
// test for issue #511
87-
installer.installFromHxml("target-lib.hxml", (libs) -> {
88-
assertEquals(1, Lambda.count(libs, (lib) -> lib.name == "hxcpp"));
89-
return false;
90-
});
91-
92-
// specified explicitly with non-standard capitalisation
93-
installer.installFromHxml("target-lib-uppercase.hxml", (libs) -> {
94-
assertEquals(1, Lambda.count(libs, (lib) -> lib.name == "HXCPP"));
95-
assertEquals(0, Lambda.count(libs, (lib) -> lib.name == "hxcpp"));
96-
return false;
97-
});
98-
}
99-
10078
public function testReinstallHxml() {
10179
installer.installFromHxml("git-deps.hxml");
10280

test/tests/TestLibFlagData.hx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package tests;
2+
3+
import haxe.io.Path;
4+
import haxelib.api.LibFlagData;
5+
6+
using Lambda;
7+
8+
class TestLibFlagData extends TestBase {
9+
10+
static var CWD:String = null;
11+
12+
override function setup() {
13+
CWD = Sys.getCwd();
14+
15+
final dir = Path.join([CWD, "test/libraries/InstallDeps"]);
16+
Sys.setCwd(dir);
17+
}
18+
19+
override function tearDown() {
20+
Sys.setCwd(CWD);
21+
}
22+
23+
function testTargetFlag() {
24+
final libraries = fromHxml("cpp.hxml");
25+
26+
assertEquals(1, libraries.count(f -> f.name == "hxcpp"));
27+
28+
final libraries = fromHxml("cpp-single.hxml");
29+
30+
assertEquals(1, libraries.count(f -> f.name == "hxcpp"));
31+
}
32+
33+
// test for issue #511
34+
function testBackendExplicit() {
35+
final libraries = fromHxml("target-lib.hxml");
36+
37+
assertEquals(1, libraries.count(f -> f.name == "hxcpp"));
38+
}
39+
40+
// specified explicitly with non-standard capitalisation
41+
function testBackendExplicitUppercase() {
42+
final libraries = fromHxml("target-lib-uppercase.hxml");
43+
44+
assertEquals(1, libraries.count(f -> f.name == "HXCPP"));
45+
assertEquals(0, libraries.count(f -> f.name == "hxcpp"));
46+
}
47+
48+
}

0 commit comments

Comments
 (0)