Skip to content
This repository has been archived by the owner on Sep 22, 2019. It is now read-only.

Commit

Permalink
added metafiles
Browse files Browse the repository at this point in the history
added pawn tests
  • Loading branch information
Southclaws committed Jan 5, 2019
1 parent 4127639 commit 70909eb
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
#
# Package only files
#

# Compiled Bytecode
*.amx

# Vendor directory for dependencies
dependencies/

# Dependency versions lockfile
pawn.lock


#
# Server/gamemode related files
#

# compiled settings file
# keep `samp.json` file on version control
# but make sure the `rcon_password` field is set externally
# you can use the environment variable `SAMP_RCON_PASSWORD` to do this.
server.cfg

# Plugins directory
plugins/

# binaries
*.exe
*.dll
*.so
announce
samp03svr
samp-npc

# logs
logs/
server_log.txt

#
# Common files
#

*.sublime-workspace
*.sublime-project

build/
.vs/
*.so
*.o

#
# Rust
#

/target
**/*.rs.bk
Expand Down
59 changes: 59 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build only",
"type": "shell",
"command": "sampctl package build",
"group": {
"kind": "build",
"isDefault": true
},
"isBackground": false,
"presentation": {
"reveal": "silent",
"panel": "dedicated"
},
"problemMatcher": "$sampctl"
},
{
"label": "build watcher",
"type": "shell",
"command": "sampctl package build --watch",
"group": "build",
"isBackground": true,
"presentation": {
"reveal": "silent",
"panel": "dedicated"
},
"problemMatcher": "$sampctl"
},
{
"label": "run tests",
"type": "shell",
"command": "sampctl package run",
"group": {
"kind": "test",
"isDefault": true
},
"isBackground": true,
"presentation": {
"reveal": "silent",
"panel": "dedicated"
},
"problemMatcher": "$sampctl"
},
{
"label": "run tests watcher",
"type": "shell",
"command": "sampctl package run --watch",
"group": "test",
"isBackground": true,
"presentation": {
"reveal": "silent",
"panel": "dedicated"
},
"problemMatcher": "$sampctl"
}
]
}
44 changes: 44 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -
# Development
# -

build-release:
cargo +stable-i686-pc-windows-msvc build --release
cp target/release/pawn_templates.dll test/plugins/templates.dll

build-debug:
cargo +stable-i686-pc-windows-msvc build --debug
cp target/debug/pawn_templates.dll test/plugins/templates.dll

# -
# Setup test requirements
# -

test-setup:
cd test && sampctl server ensure
sampctl package ensure

# -
# Run Tests
# -

test-native:
sampctl package build
cd test && sampctl server run

test-container:
sampctl package build
cd test && sampctl server run --container

# -
# Build inside container
# -

build-container:
rm -rf build
docker build -t southclaws/projectname-build .
docker run -v $(shell pwd)/test/plugins:/root/test/plugins southclaws/projectname-build

# this make target is only run inside the container
build-inside:
cd build && cmake .. && make
20 changes: 20 additions & 0 deletions pawn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"user": "Southclaws",
"repo": "pawn-templates",
"entry": "test.pwn",
"output": "test/gamemodes/test.amx",
"dependencies": ["Southclaws/samp-stdlib"],
"dev_dependencies": ["pawn-lang/YSI-Includes"],
"resources": [
{
"name": "templates.so",
"archive": false,
"platform": "linux"
},
{
"name": "templates.dll",
"archive": false,
"platform": "windows"
}
]
}
14 changes: 14 additions & 0 deletions templates.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// built-in include guard removal
// just in case the user has a local dependency with the same file name
#if defined _inc_templates
#undef _inc_templates
#endif
// custom include-guard to ensure we don't duplicate
#if defined _templates_included
#endinput
#endif
#define _templates_included


native Template:CreateTemplate(const template[]);
native RenderTemplate(Template:id, dest[]);
22 changes: 22 additions & 0 deletions test.pwn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#define RUN_TESTS

#include <a_samp>
#include <YSI\y_testing>

#include "templates.inc"

main() {
//
}

Test:Simple() {
new Template:t = CreateTemplate("Hello, {{ name }}!");
new rendered[64];
new ret = RenderTemplate(t, rendered);

printf("ret: %d", ret);
printf("rendered: %s", rendered);

ASSERT(ret == 0);
// ASSERT(!strcmp(rendered, "Hello, Southclaws!"));
}
9 changes: 9 additions & 0 deletions test/samp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"gamemodes": ["test"],
"plugins": ["templates"],
"rcon_password": ";,JoTh856/:?",
"port": 7777,
"hostname": "test",
"maxplayers": 32,
"mode": "y_testing"
}

0 comments on commit 70909eb

Please sign in to comment.