Variant invoke_file(CStrRef path, bool once /* = false */, LVariableTable* variables /* = NULL */, const char *currentDir /* = NULL */) { String cmd = canonicalize_path(path, "", 0); if (path == "string") { echo("Hello, world!"); return true; } if (cmd == "pageletserver") { SystemGlobals *g = (SystemGlobals*)get_global_variables(); echo("pagelet postparam: "); echo(g->GV(HTTP_RAW_POST_DATA)); echo("pagelet getparam: "); echo(g->GV(_GET)["getparam"]); echo("pagelet header: "); echo(g->GV(_SERVER)["HTTP_MYHEADER"]); f_header("ResponseHeader: okay"); sleep(1); // give status check time to happen return true; } return false; }
void CCTestFrame::Start() { if (m_ParserCtrl) m_ParserCtrl->SetSelection(1); // make sure "Output" tab is selected CCTestAppGlobal::s_includeDirs.Clear(); CCTestAppGlobal::s_fileQueue.Clear(); CCTestAppGlobal::s_filesParsed.Clear(); // Obtain all include directories wxStringTokenizer tkz_inc(m_IncludeCtrl->GetValue(), _T("\r\n")); while ( tkz_inc.HasMoreTokens() ) { wxString include = tkz_inc.GetNextToken().Trim(true).Trim(false); if (!include.IsEmpty()) CCTestAppGlobal::s_includeDirs.Add(include); } if (m_DoHeadersCtrl->IsChecked()) { // Obtain all priority header files wxStringTokenizer tkz_hdr(m_HeadersCtrl->GetValue(), _T(",")); while (tkz_hdr.HasMoreTokens()) { wxString header = tkz_hdr.GetNextToken().Trim(false).Trim(true); // Remove <> (if any) int lt = header.Find(wxT('<')); int gt = header.Find(wxT('>'),true); if (lt!=wxNOT_FOUND && gt!=wxNOT_FOUND && gt>lt) header = header.AfterFirst(wxT('<')).BeforeLast(wxT('>')); // Remove "" (if any) int oq = header.Find(wxT('"')); int cq = header.Find(wxT('"'),true); if (oq!=wxNOT_FOUND && cq!=wxNOT_FOUND && cq>oq) header = header.AfterFirst(wxT('"')).BeforeLast(wxT('"')); header = header.Trim(false).Trim(true); // Find the header files in include path's as provided // (practically the same as ParserBase::FindFileInIncludeDirs()) for (size_t i=0; i<CCTestAppGlobal::s_includeDirs.GetCount(); ++i) { // Normalize the path (as in C::B's "NormalizePath()") wxFileName f_header(header); wxString base_path(CCTestAppGlobal::s_includeDirs[i]); if (f_header.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE, base_path)) { wxString this_header = f_header.GetFullPath(); if ( ::wxFileExists(this_header) ) CCTestAppGlobal::s_fileQueue.Add(this_header); } } } } if (CCTestAppGlobal::s_fileQueue.IsEmpty() && !m_Control->GetLength()) { wxMessageBox(wxT("Main file not found and buffer empty. Nothing to do."), _("Information"), wxOK | wxICON_INFORMATION, this); return; } if (m_DoHideCtrl && m_DoHideCtrl->IsChecked()) Hide(); m_ProgDlg = new wxProgressDialog(_T("Please wait, operating..."), _("Preparing...\nPlease wait..."), 0, this, wxPD_APP_MODAL); m_ProgDlg->SetSize(640,100); m_ProgDlg->Layout(); m_ProgDlg->CenterOnParent(); m_LogCount = 0; m_LogCtrl->Clear(); CCTest::Get()->Clear(); // initial clearance // make sure not to over-write an existing file (in case content had changed) wxString tf(wxFileName::CreateTempFileName(wxT("cc"))); // make the parser recognise it as header file: wxFileName fn(tf); fn.SetExt(wxT("h")); wxRemoveFile(tf); // no longer needed if (m_Control->SaveFile(fn.GetFullPath())) CCTestAppGlobal::s_fileQueue.Add(fn.GetFullPath()); else AppendToLog(_T("Unable to parse buffer (could not convert to file).")); AppendToLog(_T("--------------M-a-i-n--L-o-g--------------\r\n\r\n")); // parse file from the queue one-by-one while (!CCTestAppGlobal::s_fileQueue.IsEmpty()) { wxString file = CCTestAppGlobal::s_fileQueue.Item(0); CCTestAppGlobal::s_fileQueue.Remove(file); if (file.IsEmpty()) continue; AppendToLog(_T("-----------I-n-t-e-r-i-m--L-o-g-----------")); m_CurrentFile = file; m_ProgDlg->Update(-1, m_CurrentFile); m_StatuBar->SetStatusText(m_CurrentFile); // This is the core parse stage for files CCTest::Get()->Start(m_CurrentFile); CCTestAppGlobal::s_filesParsed.Add(m_CurrentFile); // done } // don't forget to remove the temporary file (w/ ".h" extension) wxRemoveFile(fn.GetFullPath()); m_ProgDlg->Update(-1, wxT("Creating tree log...")); AppendToLog(_T("--------------T-r-e-e--L-o-g--------------\r\n")); CCTest::Get()->PrintTree(); m_ProgDlg->Update(-1, wxT("Creating list log...")); AppendToLog(_T("--------------L-i-s-t--L-o-g--------------\r\n")); CCTest::Get()->PrintList(); if (m_DoTreeCtrl->IsChecked()) { m_ProgDlg->Update(-1, wxT("Serializing tree...")); Freeze(); m_TreeCtrl->SetValue( CCTest::Get()->SerializeTree() ); Thaw(); } // Here we are going to test the expression solving algorithm NativeParserTest nativeParserTest; wxString exp = _T("obj.m_Member1"); TokenIdxSet searchScope; searchScope.insert(-1); TokenIdxSet result; TokenTree *tree = CCTest::Get()->GetTokenTree(); nativeParserTest.TestExpression(exp, tree, searchScope, result ); wxLogMessage(_T("Result have %lu matches"), static_cast<unsigned long>(result.size())); for (TokenIdxSet::iterator it=result.begin(); it!=result.end(); ++it) { Token* token = tree->at(*it); if (token) { wxString log; log << token->GetTokenKindString() << _T(" ") << token->DisplayName() << _T("\t[") << token->m_Line << _T(",") << token->m_ImplLine << _T("]"); CCLogger::Get()->Log(log); } } if (m_ProgDlg) { delete m_ProgDlg; m_ProgDlg = 0; } if ( !IsShown() ) Show(); TokenTree* tt = CCTest::Get()->GetTokenTree(); if (tt) { AppendToLog((wxString::Format(_("The parser contains %lu tokens, found in %lu files."), static_cast<unsigned long>(tt->size()), static_cast<unsigned long>(tt->m_FileMap.size())))); } }
bool TestExtNetwork::test_headers_sent() { f_header("Location: http://www.facebook.com"); VERIFY(!f_headers_sent()); return Count(true); }
bool TestExtNetwork::test_headers_list() { f_header("Location: http://www.facebook.com"); VS(f_headers_list(), Array()); return Count(true); }