Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eval] https tests #11638

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions tests/unit/src/unit/TestHttps.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package unit;

import utest.Async;

class TestHttps extends Test {
static final RUN_HTTPS_TESTS =
#if !github false && #end // comment out line to run https tests locally
#if (github && flash)
false
#elseif (js && !nodejs)
js.Browser.supported
#else
true
#end;

function run(async:Async, test:()->Void) {
if (RUN_HTTPS_TESTS) {
test();
return;
}
noAssert();
async.done();
}

// Check if http is working for this target before blaming https
@:timeout(3000)
public function testDownloadHttp(async:Async) run(async, () -> {
final url = 'http://build.haxe.org/builds/haxe/linux64/haxe_latest.tar.gz';
var req = new haxe.Http(url);
req.onBytes = bytes -> {
noAssert();
async.done();
}
req.onError = e -> {
assert('Failed Http request with string data: $e');
async.done();
}
req.request();
});

@:timeout(3000)
public function testDownloadHttps(async:Async) run(async, () -> {
#if python
if (Sys.systemName() == "Windows") {
noAssert();
return async.done();
}
#end

final url = 'https://build.haxe.org/builds/haxe/linux64/haxe_latest.tar.gz';
var req = new haxe.Http(url);
req.onBytes = bytes -> {
noAssert();
async.done();
}
req.onError = e -> {
assert('Failed Https request with string data: $e');
async.done();
}
req.request();
});
}
3 changes: 3 additions & 0 deletions tests/unit/src/unit/TestMain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ function main() {
new TestNumericCasts(),
new TestHashMap(),
new TestRest(),
#if (!php && !lua)
new TestHttps(),
#end
#if !no_pattern_matching
new TestMatch(),
#end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#if (cpp || hl || (neko && !macro && !interp))
// TODO: python is fine on unix but not on windows
#if (sys && !lua && !php && !python)
var r = haxe.Http.requestUrl("https://raw.githubusercontent.com/HaxeFoundation/haxe/development/tests/unit/res1.txt");
r == "Héllo World !";
#else
true == true;
#end
Loading