Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
# BASIC_PACKAGES is used fo the basic tools (make)
BASIC_PACKAGES: git build-essential ccache libgc-dev graphviz libunwind-dev libreadline-dev pkg-config
# MORE_PACKAGES is used for more tools and libs (make more)
MORE_PACKAGES: libgmp-dev libcurl4-openssl-dev libevent-dev openjdk-17-jdk-headless libgles-dev libegl-dev libsdl1.2-dev libsdl2-dev libsdl2-mixer-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-net-dev libsdl2-ttf-dev libgtk-3-dev inkscape postgresql libxdg-basedir-dev gettext libsqlite3-dev libpq-dev libmongoc-dev openmpi-bin libopenmpi-dev
MORE_PACKAGES: libgmp-dev libcurl4-openssl-dev libevent-dev openjdk-17-jdk-headless libgles-dev libegl-dev libsdl1.2-dev libsdl2-dev libsdl2-mixer-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-net-dev libsdl2-ttf-dev libgtk-3-dev inkscape postgresql libxdg-basedir-dev gettext libsqlite3-dev libpq-dev libmongoc-dev openmpi-bin libopenmpi-dev clang gobjc glslang-tools emscripten
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64/
JNI_LIB_PATH: /usr/lib/jvm/java-17-openjdk-amd64/lib/server/
LD_LIBRARY_PATH: /usr/lib/jvm/java-17-openjdk-amd64/lib/server/
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
path: 'tests/out/*.res`'
path: 'tests/out/*.res'
name: tests-full-${{ matrix.engine }}-res

nitunit-some:
Expand Down
14 changes: 0 additions & 14 deletions contrib/pep8analysis/src/pep8analysis_web.nit
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,10 @@ redef class AnalysisManager

fun run_web(src: String)
do
sys.suggest_garbage_collection

var stream = new StringReader(src)
var ast = build_ast("web", stream)
if ast == null then return

sys.suggest_garbage_collection

if failed then exit 1

# Build program model
Expand All @@ -67,31 +63,21 @@ redef class AnalysisManager
return
end

sys.suggest_garbage_collection

# Create CFG
var cfg = build_cfg(model)
if failed then exit 1

# Run analyses

sys.suggest_garbage_collection

## Reaching defs
do_reaching_defs_analysis(cfg)

sys.suggest_garbage_collection

## Range
do_range_analysis(ast, cfg)

sys.suggest_garbage_collection

## Types
do_types_analysis(ast, cfg)

sys.suggest_garbage_collection

print_notes
if notes.is_empty then print "Success: Nothing wrong detected"

Expand Down
104 changes: 0 additions & 104 deletions lib/curl/examples/curl_http.nit

This file was deleted.

46 changes: 46 additions & 0 deletions lib/curl/examples/curl_http_download.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This file is part of NIT ( http://www.nitlanguage.org ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Example of downloading a file with the Curl module
module curl_http_download is example

import curl

# Download `url` to the local file `file_path`
fun http_download(url, file_path: String): CurlResponse
do
var request = new CurlHTTPRequest(url)
request.verbose = false # Set to `true` to debug

# Custom header
var headers = new HeaderMap
headers["Accept"] = "Moo"
request.headers = headers

return request.download_to_file(file_path)
end

if args.length != 2 then
print "Usage: curl_http_download url file"
exit 1
end

var response = http_download(args[0], args[1])
if response isa CurlFileResponseSuccess then
print "Status code: {response.status_code}"
print "Size downloaded: {response.size_download}"
else if response isa CurlResponseFailed then
print "Error code: {response.error_code}"
print "Error msg: {response.error_msg}"
end
40 changes: 40 additions & 0 deletions lib/curl/examples/curl_http_get.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file is part of NIT ( http://www.nitlanguage.org ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Example of an HTTP GET request with the Curl module
module curl_http_get is example

import curl

# Execute an HTTP GET request on `url`
fun http_get(url: String): CurlResponse
do
var request = new CurlHTTPRequest(url)
request.verbose = false # Set to `true` to debug
return request.execute
end

if args.length != 1 then
print "Usage: curl_http_get url"
exit 1
end

var response = http_get(args.first)
if response isa CurlResponseSuccess then
print "Status code: {response.status_code}"
print "Body: {response.body_str}"
else if response isa CurlResponseFailed then
print "Error code: {response.error_code}"
print "Error msg: {response.error_msg}"
end
93 changes: 93 additions & 0 deletions lib/curl/examples/curl_http_local_server.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# This file is part of NIT ( http://www.nitlanguage.org ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Run the `curl_http_*` examples against the local `nitcorn_hello_world` server
#
# The server answers with the content of the hello world Web site.
# This is mainly used by the tests.
module curl_http_local_server is example

import curl_http_get
import curl_http_post
import curl_http_download
import nitcorn::nitcorn_hello_world
import pthreads

# Port of the local server, unique to each run of the tests
fun local_port: Int
do
var testing_id = "NIT_TESTING_ID".environ
if testing_id.is_int then return 20000 + testing_id.to_i % 10000
return 20000
end

# Thread running the local server
class ServerThread
super Thread

redef fun main
do
# Hide the testing concept from nitcorn to force it to actually run
"NIT_TESTING".setenv("false")

# The file server of the example is not used, only its dynamic pages
hello_world_server("localhost:{local_port}", ".")
return null
end
end

# Print the status of `response`, or its error
fun print_response(response: CurlResponse)
do
if response isa CurlResponseSuccess then
print "Status code: {response.status_code}"
else if response isa CurlFileResponseSuccess then
print "Status code: {response.status_code}"
else if response isa CurlResponseFailed then
print "Error code: {response.error_code}"
print "Error msg: {response.error_msg}"
end
end

var host = "http://localhost:{local_port}"

# Launch the server in the background
var server = new ServerThread
server.start
0.1.sleep

print "# GET"

var get_response = http_get(host / "index.html")
print_response get_response
if get_response isa CurlResponseSuccess then
print "Body: {get_response.body_str}"
end

print "# POST"

print_response http_post(host / "hello/curl")

print "# Download"

var write_dir = "WRITE".environ
if write_dir.is_empty then write_dir = "."
write_dir.mkdir

var download_response = http_download(host / "index.html",
write_dir / "index.html")
print_response download_response
if download_response isa CurlFileResponseSuccess then
print "Size downloaded: {download_response.size_download}"
end
Loading
Loading